Changeset View
Changeset View
Standalone View
Standalone View
src/Config/DefaultConfiguration.php
- This file was added.
<?php | |||||
namespace Nasqueron\SAAS\PhpBB\Config; | |||||
class DefaultConfiguration { | |||||
/// | |||||
/// Sites repository | |||||
/// | |||||
public static function getSqliteRepositoryFilename() : string { | |||||
return getenv("SAAS_SITES_DB"); | |||||
} | |||||
/// | |||||
/// MySQL database | |||||
/// | |||||
public static function getMySQLDatasourceName() : string { | |||||
$info = self::getMySQLConnectionInformation(); | |||||
return "mysql:host=$info[host];port=$info[port];charset=utf8"; | |||||
} | |||||
public static function getMySQLConnectionInformation() : array { | |||||
// There are three scenarii we test to get information: | |||||
// | |||||
// 1. Explicit preferences given in environment or .env | |||||
// 2. MySQL Docker container linked with `--link phpbb_db:db` | |||||
// 3. MySQL development default configuration | |||||
return [ | |||||
'host' => $_ENV['DB_HOST'] ?? $_ENV['DB_PORT_3306_TCP_ADDR'] ?? 'localhost', | |||||
'port' => $_ENV['DB_PORT'] ?? $_ENV['DB_PORT_3306_TCP_PORT'] ?? 3306, | |||||
'user' => $_ENV['DB_USER'] ?? 'root', | |||||
'pass' => $_ENV['DB_PASS'] ?? $_ENV['DB_ENV_MYSQL_ROOT_PASSWORD'] ?? '', | |||||
]; | |||||
} | |||||
} |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator