illuminate/database


[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

License: MIT

Language: PHP


Illuminate Database

The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite. It also serves as the database layer of the Laravel PHP framework.

Usage Instructions

First, create a new "Capsule" manager instance. Capsule aims to make configuring the library for usage outside of the Laravel framework as easy as possible.

use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => 'password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
]);

// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();

// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();

composer require "illuminate/events" required when you need to use observers with Eloquent.

Once the Capsule instance has been registered. You may use it like so:

Using The Query Builder

$users = Capsule::table('users')->where('votes', '>', 100)->get();

Other core methods may be accessed directly from the Capsule in the same manner as from the DB facade:

$results = Capsule::select('select * from users where id = ?', [1]);

Using The Schema Builder

Capsule::schema()->create('users', function ($table) {
    $table->increments('id');
    $table->string('email')->unique();
    $table->timestamps();
});

Using The Eloquent ORM

class User extends Illuminate\Database\Eloquent\Model {}

$users = User::where('votes', '>', 1)->get();

For further documentation on using the various database facilities this library provides, consult the Laravel framework documentation.

Project Statistics

Sourcerank 21
Repository Size 8.08 MB
Stars 1,929
Forks 458
Watchers 108
Open issues disabled
Dependencies 6
Contributors 669
Tags 238
Created
Last updated
Last pushed

Top Contributors See all

Taylor Otwell Graham Campbell Jonas Staudenmeir Mohamed Said Lucas Michot Joseph Silber Dries Vints Anže Časar Andreas Lutro vlakoff Anton Komarev Mior Muhammad Zaki Tetiana Blindaruk Marcin Nabiałek Dwight Watson Franz Liedke Alex Bowers Kennedy Tedesco Barry vd. Heuvel Laurence Ioannou

Packages Referencing this Repo

illuminate/database
The Illuminate Database package.
Latest release v6.6.1 - Updated - 1.93K stars

Recent Tags See all

v6.6.2 December 05, 2019
v6.6.1 November 29, 2019
v6.6.0 November 25, 2019
v6.5.2 November 15, 2019
v6.5.1 November 12, 2019
v6.5.0 November 05, 2019
v6.4.1 October 26, 2019
v6.4.1 October 26, 2019
v6.3.0 October 15, 2019
v6.2.0 October 08, 2019
v6.1.0 September 25, 2019
v6.0.4 September 20, 2019
v6.0.4 September 20, 2019
v6.0.3 September 20, 2019
v6.0.2 September 06, 2019

Interesting Forks See all

hamidionline/database
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)
PHP - Updated - 1 stars
robclancy/schema-builder
Fork of illuminate/database to provide a simple package for the schema builder alone
PHP - Last pushed - 1 stars - 1 forks
duyld-yoncode/database
The Illuminate Database modified package to works with Silex application and PHP 5.3
This repository is no longer available - 1 stars
gutao1994/database
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)
PHP - Updated - 1 stars
aaasayok/database
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)
PHP - Updated - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-12-05 14:06:23 UTC

Login to resync this repository