From 7beae0ae05355c7daf7674d6da4a67cec22b98b3 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 25 Nov 2019 23:37:12 +0100 Subject: [PATCH] Fixed config wrong compilation Fixes #112 Fixes #111 --- CHANGELOG.md | 1 + bootstrap/app.php | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d438e5b..bb59379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## v.3.0.1 + Fixed error with older mysql versions. ++ Fixed config is compiled with the di container. + Small installer update. ## v.3.0 diff --git a/bootstrap/app.php b/bootstrap/app.php index b45f96a..c5f35c1 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -27,31 +27,30 @@ if (!file_exists('config.php') && is_dir('install/')) { // Load the config $config = array_replace_recursive([ - 'app_name' => 'XBackBone', - 'base_url' => isset($_SERVER['HTTPS']) ? 'https://'.$_SERVER['HTTP_HOST'] : 'http://'.$_SERVER['HTTP_HOST'], - 'debug' => false, + 'app_name' => 'XBackBone', + 'base_url' => isset($_SERVER['HTTPS']) ? 'https://'.$_SERVER['HTTP_HOST'] : 'http://'.$_SERVER['HTTP_HOST'], + 'debug' => false, 'maintenance' => false, - 'db' => [ + 'db' => [ 'connection' => 'sqlite', - 'dsn' => BASE_DIR.'resources/database/xbackbone.db', - 'username' => null, - 'password' => null, + 'dsn' => BASE_DIR.'resources/database/xbackbone.db', + 'username' => null, + 'password' => null, ], 'storage' => [ 'driver' => 'local', - 'path' => realpath(__DIR__.'/').DIRECTORY_SEPARATOR.'storage', + 'path' => realpath(__DIR__.'/').DIRECTORY_SEPARATOR.'storage', ], ], require BASE_DIR.'config.php'); $builder = new ContainerBuilder(); if (!$config['debug']) { - $builder->enableCompilation(BASE_DIR.'/resources/cache/di/'); - $builder->writeProxiesToFile(true, BASE_DIR.'/resources/cache/proxies'); + $builder->enableCompilation(BASE_DIR.'/resources/cache/di'); + $builder->writeProxiesToFile(true, BASE_DIR.'/resources/cache/di'); } $builder->addDefinitions([ - 'config' => value($config), View::class => factory(function (Container $container) { return ViewFactory::createAppInstance($container); }), @@ -61,6 +60,7 @@ $builder->addDefinitions([ $builder->addDefinitions(__DIR__.'/container.php'); $app = Bridge::create($builder->build()); +$app->getContainer()->set('config', $config); $app->setBasePath(parse_url($config['base_url'], PHP_URL_PATH) ?: ''); if (!$config['debug']) {