diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-06 19:19:05 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-06 19:19:05 -0400 |
commit | 400e230881bc71e052ee41da660ec5ff8dd3130d (patch) | |
tree | dfe32f874dca7f93c37ac5184941a8932293119a /app/common.php | |
parent | 72dcb6fc9b48a2b0c730b499685052bf256cf3c2 (diff) |
Added support for Mysql SSL connection
Diffstat (limited to 'app/common.php')
-rw-r--r-- | app/common.php | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/app/common.php b/app/common.php index aed07a50..fa95773b 100644 --- a/app/common.php +++ b/app/common.php @@ -2,16 +2,17 @@ require __DIR__.'/../vendor/autoload.php'; -// Automatically parse environment configuration (Heroku) -if (getenv('DATABASE_URL')) { - $dbopts = parse_url(getenv('DATABASE_URL')); - - define('DB_DRIVER', $dbopts['scheme']); - define('DB_USERNAME', $dbopts["user"]); - define('DB_PASSWORD', $dbopts["pass"]); - define('DB_HOSTNAME', $dbopts["host"]); - define('DB_PORT', isset($dbopts["port"]) ? $dbopts["port"] : null); - define('DB_NAME', ltrim($dbopts["path"], '/')); +$dbUrlParser = new PicoDb\UrlParser(); + +if ($dbUrlParser->isEnvironmentVariableDefined()) { + $dbSettings = $dbUrlParser->getSettings(); + + define('DB_DRIVER', $dbSettings['driver']); + define('DB_USERNAME', $dbSettings['username']); + define('DB_PASSWORD', $dbSettings['password']); + define('DB_HOSTNAME', $dbSettings['hostname']); + define('DB_PORT', $dbSettings['port']); + define('DB_NAME', $dbSettings['database']); } $config_file = implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'config.php')); @@ -30,18 +31,18 @@ require __DIR__.'/constants.php'; require __DIR__.'/check_setup.php'; $container = new Pimple\Container; -$container->register(new Kanboard\ServiceProvider\HelperProvider); -$container->register(new Kanboard\ServiceProvider\SessionProvider); -$container->register(new Kanboard\ServiceProvider\LoggingProvider); -$container->register(new Kanboard\ServiceProvider\DatabaseProvider); -$container->register(new Kanboard\ServiceProvider\AuthenticationProvider); -$container->register(new Kanboard\ServiceProvider\NotificationProvider); -$container->register(new Kanboard\ServiceProvider\ClassProvider); -$container->register(new Kanboard\ServiceProvider\EventDispatcherProvider); -$container->register(new Kanboard\ServiceProvider\GroupProvider); -$container->register(new Kanboard\ServiceProvider\RouteProvider); -$container->register(new Kanboard\ServiceProvider\ActionProvider); -$container->register(new Kanboard\ServiceProvider\ExternalLinkProvider); -$container->register(new Kanboard\ServiceProvider\AvatarProvider); -$container->register(new Kanboard\ServiceProvider\FilterProvider); -$container->register(new Kanboard\ServiceProvider\PluginProvider); +$container->register(new Kanboard\ServiceProvider\HelperProvider()); +$container->register(new Kanboard\ServiceProvider\SessionProvider()); +$container->register(new Kanboard\ServiceProvider\LoggingProvider()); +$container->register(new Kanboard\ServiceProvider\DatabaseProvider()); +$container->register(new Kanboard\ServiceProvider\AuthenticationProvider()); +$container->register(new Kanboard\ServiceProvider\NotificationProvider()); +$container->register(new Kanboard\ServiceProvider\ClassProvider()); +$container->register(new Kanboard\ServiceProvider\EventDispatcherProvider()); +$container->register(new Kanboard\ServiceProvider\GroupProvider()); +$container->register(new Kanboard\ServiceProvider\RouteProvider()); +$container->register(new Kanboard\ServiceProvider\ActionProvider()); +$container->register(new Kanboard\ServiceProvider\ExternalLinkProvider()); +$container->register(new Kanboard\ServiceProvider\AvatarProvider()); +$container->register(new Kanboard\ServiceProvider\FilterProvider()); +$container->register(new Kanboard\ServiceProvider\PluginProvider()); |