-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphpmig.php
executable file
·22 lines (22 loc) · 1.04 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
<?php
use \Illuminate\Database\Capsule\Manager as Capsule;
use \Phpmig\Adapter;
use \Pimple as Pimple;
$container = new Pimple();
$container['db'] = $container->share(function () {
$dbh = new PDO(Config::database('driver') . ':dbname=' . Config::database('database') . ';port=' . Config::database('port') . ';host=' . Config::database('host'), Config::database('username'), Config::database('password'));
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
});
$container['schema'] = $container->share(function () {
$capsule = new Capsule;
$capsule->addConnection(Config::database());
$capsule->setAsGlobal();
return Capsule::schema();
});
$container['phpmig.adapter'] = $container->share(function () use ($container) {
return new Adapter\PDO\Sql($container['db'], 'migrations');
});
$container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . 'app/migrations';
$container['phpmig.migrations_template_path'] = __DIR__ . DIRECTORY_SEPARATOR . 'app/migrations/template/migration.php';
return $container;