You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
useIlluminate\Database\Capsule\ManagerasCapsule;
$capsule = newCapsule;
$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)useIlluminate\Events\Dispatcher;
useIlluminate\Container\Container;
$capsule->setEventDispatcher(newDispatcher(newContainer));
// 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: