diff --git a/index.php b/index.php index efffa15..1bf31c3 100644 --- a/index.php +++ b/index.php @@ -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(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 3d95858..0251786 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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'));