<?php $app = (require_once __DIR__ . '/bootstrap.php'); use Phpmig\Adapter, Phpmig\Pimple\Pimple; $container = new Pimple(); $container['pdo'] = $app->pdo; $container['app'] = $app; $container['phpmig.adapter'] = $container->share(function () use($app) { return new Adapter\PDO\Sql($app->pdo, 'migrations'); }); $container['phpmig.migrations'] = function () { return glob(__DIR__ . DIRECTORY_SEPARATOR . 'migrations/*.php'); }; return $container;
<?php define('ENVIRONMENT', isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'local'); $config = array(); require_once "config.php"; use Phpmig\Pimple\Pimple, Illuminate\Database\Capsule\Manager as Capsule, Phpmig\Adapter; $container = new Pimple(); $container['config'] = $db[ENVIRONMENT]; $container['schema'] = $container->share(function ($c) { /* Bootstrap Eloquent */ $capsule = new Capsule(); $capsule->addConnection($c['config']); $capsule->setAsGlobal(); /* Bootstrap end */ return Capsule::schema(); }); $container['db'] = $container->share(function ($c) { $dbh = new PDO('mysql:dbname=' . $c['config']['database'] . ';host=' . $c['config']['hostname'], $c['config']['username'], $c['config']['password']); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $dbh; }); $container['phpmig.adapter'] = $container->share(function () use($container) { return new Adapter\PDO\Sql($container['db'], 'migrations'); }); $container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . 'migrations'; return $container;
<?php use Phpmig\Adapter; use Phpmig\Pimple\Pimple, Illuminate\Database\Capsule\Manager as Capsule; use Dotenv\Dotenv; /* * Load env */ $dotenv = new Dotenv(realpath(__DIR__)); $dotenv->load(); $container = new Pimple(); $container['config'] = ['driver' => 'mysql', 'host' => env('DB_UOM_HOST'), 'database' => env('DB_UOM_DATABASE'), 'username' => env('DB_UOM_USERNAME'), 'password' => env('DB_UOM_PASSWORD'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']; $container['db'] = $container->share(function () use($container) { $capsule = new Capsule(); $capsule->addConnection($container['config']); $capsule->setAsGlobal(); $capsule->bootEloquent(); return $capsule; }); $container['phpmig.adapter'] = $container->share(function () use($container) { return new Adapter\Illuminate\Database($container['db'], 'migrations'); }); $container['phpmig.migrations_path'] = function () { return __DIR__ . DIRECTORY_SEPARATOR . 'migrations'; }; $container['phpmig.migrations_template_path'] = function () { return __DIR__ . DIRECTORY_SEPARATOR . 'migrations/template/migration-template.php'; }; return $container;