-
Notifications
You must be signed in to change notification settings - Fork 4
/
phinx.php
58 lines (49 loc) · 1.65 KB
/
phinx.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
48
49
50
51
52
53
54
55
56
57
58
<?php
define('BASE_ROOT', dirname(__FILE__));
define('VENDOR_ROOT', BASE_ROOT.'/vendor');
define('CONFIG_ROOT', BASE_ROOT.'/config');
define('RESOURCES_ROOT', BASE_ROOT.'/resources');
define('STORAGE_ROOT', BASE_ROOT.'/storage');
define('APP_ROOT', BASE_ROOT.'/app');
// Import
use Illuminate\Database\Capsule\Manager as Capsule;
use Slimork\Foundation\App;
// Config
$app = new App();
$app->loadBeforeBootstrappers();
$app->loadAppCore();
$app->loadAfterBootstrappers();
$app->loadRoutes();
$config = $app->getContainer()->get('settings');
// Initial
date_default_timezone_set($config['app']['timezone']);
// Database
$databaseConfig = $config['database'];
$databaseConnections = $databaseConfig['connections'];
$defaultConnection = $databaseConnections[$databaseConfig['default']];
$capsule = new Capsule;
foreach($databaseConnections as $name => $connection) {
$capsule->addConnection(
$connection,
(strtolower($databaseConfig['default']) == $name) ? "default" : $name
);
}
$capsule->setAsGlobal();
$capsule->bootEloquent();
// Return
return [
'paths' => [
'migrations' => BASE_ROOT.'/database/migrations',
'seeds' => BASE_ROOT.'/database/seeds'
],
'migration_base_class' => Simork\Contracts\Migration::class,
'environments' => [
'default_migration_table' => $defaultConnection['prefix'].$databaseConfig['migration']['table'],
'default_database' => 'default',
'default' => [
'connection' => $capsule->getConnection()->getPdo(),
'name' => $defaultConnection['database'],
'table_prefix' => $defaultConnection['prefix']
]
],
];