Skip to content

Instantly share code, notes, and snippets.

@jhonata-menezes-forseti
Created January 13, 2017 16:52
Show Gist options
  • Save jhonata-menezes-forseti/82e93284dec8b8e6af81d5dfec0b1d48 to your computer and use it in GitHub Desktop.
Save jhonata-menezes-forseti/82e93284dec8b8e6af81d5dfec0b1d48 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$configDatabase = require_once __DIR__ . '/config/global.php';
$capsule->addConnection($configDatabase['database']['mysql']);
// 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();
//$capsule->getConnection('default')->enableQueryLog();
//$capsule->getConnection('default')->listen(function($sql){
// var_dump($sql->sql, $sql->bindings);
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment