diff --git a/.drone.yml b/.drone.yml index 70ae716..22c6757 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,7 @@ steps: - name: code checks image: composer commands: - - composer install + - composer install --no-ansi --no-interaction + - ./bin/setup - ./vendor/bin/php-cs-fixer fix --dry-run src - - ./vendor/bin/phpstan analyse src + - ./vendor/bin/phpstan analyse -a config/autoload_with_route.php src diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..20f42f0 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env php +env !== 'prod' || !file_exists($compiledRoutesFile)) { $routes = include(__DIR__ . '/../config/routes.php'); @@ -70,8 +69,9 @@ class Main $compiler->writeCache(); } - include(__DIR__ . '/../var/cache/routes.php'); - return new CompiledRoutes(); + include(__DIR__ . '/../var/cache/routes/CompiledRoutes.php'); + $x = "\CubiStore\Web\Cache\CompiledRoutes"; + return new $x(); } public function setupContainer(ICompiledRoutes $routes) diff --git a/src/Utils/RouteCompiler.php b/src/Utils/RouteCompiler.php index 1197ca2..53ce276 100644 --- a/src/Utils/RouteCompiler.php +++ b/src/Utils/RouteCompiler.php @@ -46,6 +46,12 @@ class RouteCompiler public function writeCache() { + $dirname = dirname($this->target); + + if (!is_dir($dirname)) { + mkdir($dirname, 0777, true); + } + file_put_contents($this->target, $this->compile()); }