-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathphpmig.php
37 lines (27 loc) · 1.07 KB
/
phpmig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
define('ENVIRONMENT', isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'production');
$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']['host'], $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;