/
phpmig.php
47 lines (38 loc) · 1.2 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
38
39
40
41
42
43
44
45
46
47
<?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;