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 7.74 MB
Stars 1,851
Forks 438
Watchers 108
Open issues disabled
Dependencies 5
Contributors 651
Tags 216
Created
Last updated
Last pushed

Top Contributors See all

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

Packages Referencing this Repo

illuminate/database
The Illuminate Database package.
Latest release v5.8.30 - Updated - 1.85K stars

Recent Tags See all

v5.8.31 August 06, 2019
v5.8.30 July 29, 2019
v5.8.29 July 15, 2019
v5.8.28 June 28, 2019
v5.8.27 June 28, 2019
v5.8.24 June 16, 2019
v5.8.22 June 11, 2019
v5.8.20 June 04, 2019
v5.8.19 May 27, 2019
v5.8.18 May 15, 2019
v5.8.17 May 13, 2019
v5.8.15 April 30, 2019
v5.8.14 April 22, 2019
v5.8.12 April 15, 2019
v5.8.11 April 10, 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-08-06 15:46:17 UTC

Login to resync this repository