diff --git a/app/src/Bootstrap/BootManager.php b/app/src/Bootstrap/BootManager.php index 221ec6e..ab17611 100644 --- a/app/src/Bootstrap/BootManager.php +++ b/app/src/Bootstrap/BootManager.php @@ -14,7 +14,7 @@ class BootManager ...glob($configPath . '/*.php') ); - if (self::enableContainerCompilation()) { + if (self::containerCompilationEnabled()) { $container->enableCompilation($cachePath); } @@ -22,16 +22,18 @@ class BootManager } /** Determine if container compilation should be enabled. */ - protected static function enableContainerCompilation(): bool + protected static function containerCompilationEnabled(): bool { if (filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOL)) { return false; } - if (! filter_var(getenv('COMPILE_CONTAINER'), FILTER_VALIDATE_BOOL)) { - return false; + $compileContainer = getenv('COMPILE_CONTAINER'); + + if ($compileContainer === false) { + return true; } - return true; + return strtolower($compileContainer) !== 'false'; } } diff --git a/index.php b/index.php index 7c11f10..6323471 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,6 @@ use App\Bootstrap\AppManager; use App\Bootstrap\BootManager; -use DI\ContainerBuilder; use Dotenv\Dotenv; require __DIR__ . '/app/vendor/autoload.php'; diff --git a/tests/Bootstrap/BootManagerTest.php b/tests/Bootstrap/BootManagerTest.php index ee2bd03..9ee9504 100644 --- a/tests/Bootstrap/BootManagerTest.php +++ b/tests/Bootstrap/BootManagerTest.php @@ -22,10 +22,9 @@ class BootManagerTest extends TestCase } /** @test */ - public function it_caches_the_container_when_compile_container_is_true(): void + public function it_caches_the_container_by_default(): void { - putenv('APP_DEBUG=false'); - putenv('COMPILE_CONTAINER=true'); + putenv('COMPILE_CONTAINER='); $container = BootManager::createContainer( $this->filePath('app/config'), @@ -37,9 +36,8 @@ class BootManagerTest extends TestCase } /** @test */ - public function it_does_not_cache_the_container_when_compilation_is_explicitly_disabled(): void + public function it_does_not_cache_the_container_when_explicitly_disabled(): void { - putenv('APP_DEBUG=false'); putenv('COMPILE_CONTAINER=false'); $container = BootManager::createContainer( @@ -55,7 +53,6 @@ class BootManagerTest extends TestCase public function it_does_not_cache_the_container_when_debug_is_enabled(): void { putenv('APP_DEBUG=true'); - putenv('COMPILE_CONTAINER=true'); $container = BootManager::createContainer( $this->filePath('app/config'),