getenv('SS_DATABASE_CLASS') ?: 'MySQLPDODatabase', "server" => getenv('SS_DATABASE_SERVER') ?: 'localhost', "username" => $dbUser, "password" => getenv('SS_DATABASE_PASSWORD'), "database" => $databaseNameWrapper($database), ); // Set the port if called for if ($dbPort = getenv('SS_DATABASE_PORT')) { $databaseConfig['port'] = $dbPort; } // Set the timezone if called for if ($dbTZ = getenv('SS_DATABASE_TIMEZONE')) { $databaseConfig['timezone'] = $dbTZ; } // For schema enabled drivers: if ($dbSchema = getenv('SS_DATABASE_SCHEMA')) { $databaseConfig["schema"] = $dbSchema; } // For SQlite3 memory databases (mainly for testing purposes) if ($dbMemory = getenv('SS_DATABASE_MEMORY')) { $databaseConfig["memory"] = $dbMemory; } } if ($sendAllEmailsTo = getenv('SS_SEND_ALL_EMAILS_TO')) { Email::config()->send_all_emails_to = $sendAllEmailsTo; } if ($sendAllEmailsFrom = getenv('SS_SEND_ALL_EMAILS_FROM')) { Email::config()->send_all_emails_from = $sendAllEmailsFrom; } if ($defaultAdminUser = getenv('SS_DEFAULT_ADMIN_USERNAME')) { if (!$defaultAdminPass = getenv('SS_DEFAULT_ADMIN_PASSWORD')) { user_error( "SS_DEFAULT_ADMIN_PASSWORD must be defined in your environment," . "if SS_DEFAULT_ADMIN_USERNAME is defined. See " . "http://doc.silverstripe.org/framework/en/topics/environment-management for more information", E_USER_ERROR ); } else { DefaultAdminService::setDefaultAdmin($defaultAdminUser, $defaultAdminPass); } } if ($useBasicAuth = getenv('SS_USE_BASIC_AUTH')) { BasicAuth::config()->entire_site_protected = $useBasicAuth; } if ($errorLog = getenv('SS_ERROR_LOG')) { $logger = Injector::inst()->get(LoggerInterface::class); if ($logger instanceof Logger) { $logger->pushHandler(new StreamHandler(BASE_PATH . '/' . $errorLog, Logger::WARNING)); } else { user_error("SS_ERROR_LOG setting only works with Monolog, you are using another logger", E_USER_WARNING); } } // Allow database adapters to handle their own configuration DatabaseAdapterRegistry::autoconfigure(); unset( $envType, $chooseName, $loopCount, $databaseDir, $i, $databaseNameWrapper, $dbUser, $dbPort, $dbTZ, $dbSchema, $dbMemory, $sendAllEmailsTo, $sendAllEmailsFrom, $defaultAdminUser, $defaultAdminPass, $useBasicAuth, $errorLog, $logger );