2016-10-27 23:53:11 +02:00
|
|
|
<?php
|
|
|
|
|
2017-01-30 16:33:56 +01:00
|
|
|
// Bootstrap environment variables
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2017-01-30 16:33:56 +01:00
|
|
|
use Dotenv\Loader;
|
|
|
|
|
|
|
|
$loader = new Loader(null);
|
|
|
|
if (!getenv('SS_ENVIRONMENT_TYPE')) {
|
|
|
|
$loader->setEnvironmentVariable('SS_ENVIRONMENT_TYPE', 'dev');
|
2016-10-27 23:53:11 +02:00
|
|
|
}
|
|
|
|
|
2017-01-30 16:33:56 +01:00
|
|
|
if (!getenv('SS_DATABASE_CLASS') && !getenv('SS_DATABASE_USERNAME')) {
|
2016-12-16 05:34:21 +01:00
|
|
|
// The default settings let us define the database config via environment vars
|
|
|
|
// Database connection, including PDO and legacy ORM support
|
|
|
|
switch (getenv('DB')) {
|
|
|
|
case "PGSQL";
|
2017-01-30 16:33:56 +01:00
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_CLASS', getenv('PDO') ? 'PostgrePDODatabase' : 'PostgreSQLDatabase');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_USERNAME', 'postgres');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_PASSWORD', '');
|
|
|
|
break;
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
case "SQLITE":
|
2017-01-30 16:33:56 +01:00
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_CLASS', getenv('PDO') ? 'SQLite3PDODatabase' : 'SQLite3Database');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_USERNAME', 'root');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_PASSWORD', '');
|
|
|
|
$loader->setEnvironmentVariable('SS_SQLITE_DATABASE_PATH', ':memory:');
|
2016-12-16 05:34:21 +01:00
|
|
|
break;
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
default:
|
2017-01-30 16:33:56 +01:00
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_CLASS', getenv('PDO') ? 'MySQLPDODatabase' : 'MySQLDatabase');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_USERNAME', 'root');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_PASSWORD', '');
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2017-01-30 16:33:56 +01:00
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_SERVER', '127.0.0.1');
|
|
|
|
$loader->setEnvironmentVariable('SS_DATABASE_CHOOSE_NAME', true);
|
2016-10-27 23:53:11 +02:00
|
|
|
}
|