Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Expected configuration config.local.neon:
- * database:
- * dsn: 'mysql:host=127.0.0.1;dbname=hicoriastatus;port=3307' # or without the ;port=XXXX
- * user: username
- * password: password
- *
- */
- $neon = \Nette\Neon\Neon();
- if (file_exists($configFile = __DIR__ . '/app/config/config.local.neon'))
- {
- $file = file_get_contents($configFile);
- } else {
- throw new \Nette\Neon\Exception('File \'config.local.neon\' not found. in ' . $configFile . '.');
- }
- $decoded = $neon->decode($file);
- $database = isset($decode['database']) ? $decoded['database'] : ['user' => '', 'password' => '', 'dsn' => 'mysql:host=localhost;dbname=database'];
- $tmp = explode(':',$database['dsn']);
- $adapter = $tmp[0];
- $tmp = explode(';', $tmp[1]);
- foreach ($tmp as $n)
- {
- $n = explode('=', $n);
- $dsn[$n[0]] = $n[1];
- }
- return [
- 'paths' => [
- 'migrations' => 'migrations',
- 'seeds' => 'migrations/seeds'
- ],
- 'environments' => [
- 'default_migration_table' => '_phinx_log',
- 'default_database' => 'production',
- 'production' => [
- 'adapter' => !empty($adapter) ? $adapter : 'mysql',
- 'host' => $dsn['host'],
- 'name' => $dsm['dbname'],
- 'user' => $database['user'],
- 'pass' => $database['password'],
- 'port' => !empty($dsn['port']) ? $dsn['port'] : 3306
- ]
- ]
- ];
Add Comment
Please, Sign In to add comment