From 400e230881bc71e052ee41da660ec5ff8dd3130d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 6 May 2016 19:19:05 -0400 Subject: Added support for Mysql SSL connection --- app/common.php | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'app/common.php') 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()); -- cgit v1.2.3