Load all files in the config directory and enable container compilation

This commit is contained in:
Chris Kankiewicz
2020-07-02 10:40:48 -07:00
parent 2a9b01d002
commit b9020d6f15
2 changed files with 14 additions and 9 deletions

View File

@@ -12,12 +12,18 @@ ini_set('open_basedir', __DIR__);
// Initialize environment variable handler
Dotenv::createUnsafeImmutable(__DIR__)->safeLoad();
// Initialize the container
$container = call_user_func_array(
[new ContainerBuilder, 'addDefinitions'],
glob(__DIR__ . '/app/config/*.php')
);
if (filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOLEAN) !== true) {
$container->enableCompilation(__DIR__ . '/app/cache');
}
// Initialize the application
$app = (new ContainerBuilder)->addDefinitions(
__DIR__ . '/app/config/cache.php',
__DIR__ . '/app/config/app.php',
__DIR__ . '/app/config/container.php'
)->build()->call(AppManager::class);
$app = $container->build()->call(AppManager::class);
// Engage!
$app->run();

View File

@@ -29,10 +29,9 @@ class TestCase extends PHPUnitTestCase
{
Dotenv::createUnsafeImmutable(__DIR__)->safeLoad();
$this->container = (new ContainerBuilder)->addDefinitions(
dirname(__DIR__) . '/app/config/cache.php',
dirname(__DIR__) . '/app/config/app.php',
dirname(__DIR__) . '/app/config/container.php'
$this->container = call_user_func_array(
[new ContainerBuilder, 'addDefinitions'],
glob(dirname(__DIR__) . '/app/config/*.php')
)->build();
$this->cache = new ArrayAdapter($this->container->get('cache_lifetime'));