Last active
August 5, 2016 21:24
-
-
Save chrisgaraffa/ebffc6a4781fdf6ac95d479fe0aed292 to your computer and use it in GitHub Desktop.
Using Eloquent ORM and EventDispatcher with CodeIgniter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Install the following via composer: | |
* "illuminate/database": "^5.2" | |
* "illuminate/events": "^5.2" | |
* Add require_once('./vendor/autoload.php'); to config/autoload.php | |
* Add this to the end of your database.php file, or your config/ENVIRONMENT/database.php file as needed: | |
*/ | |
use Illuminate\Database\Capsule\Manager as Capsule; | |
use Illuminate\Events\Dispatcher; | |
use Illuminate\Container\Container; | |
$capsule = new Capsule; | |
$capsule->addConnection(array( | |
'driver' => 'mysql', | |
'host' => $db[ENVIRONMENT]['hostname'], | |
'database' => $db[ENVIRONMENT]['database'], | |
'username' => $db[ENVIRONMENT]['username'], | |
'password' => $db[ENVIRONMENT]['password'], | |
'charset' => 'utf8', | |
'collation' => 'utf8_unicode_ci', | |
'prefix' => $db[ENVIRONMENT]['dbprefix'] | |
)); | |
$capsule->setEventDispatcher(new Dispatcher(new Container)); | |
$capsule->setAsGlobal(); | |
$capsule->bootEloquent(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment