diff --git a/.env b/.env deleted file mode 100644 index f17a4a9..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -DEBUG=true -VIEW_CACHE=true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 426c2cb..d188a20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.idea +.env +storage/cache vendor -resources/cache \ No newline at end of file +.idea \ No newline at end of file diff --git a/src/Runtime/Factory/BootstrapFactory.php b/src/Runtime/Factory/BootstrapFactory.php index b1d1815..ba05fb5 100644 --- a/src/Runtime/Factory/BootstrapFactory.php +++ b/src/Runtime/Factory/BootstrapFactory.php @@ -77,6 +77,14 @@ class BootstrapFactory { return "../resources/"; } + /** + * @return string + */ + public function storagePath() + { + return "../storage/"; + } + /** * @return ViewEngine */ diff --git a/src/Runtime/Http/View/ViewEngine.php b/src/Runtime/Http/View/ViewEngine.php index cecf9a6..78155bd 100644 --- a/src/Runtime/Http/View/ViewEngine.php +++ b/src/Runtime/Http/View/ViewEngine.php @@ -26,9 +26,13 @@ class ViewEngine extends AppFactory { { $loader = new FilesystemLoader(app()->resourcePath() . 'views'); - self::$twig = new Environment($loader, [ - //'cache' => app()->resourcePath() . 'cache' - ]); + $options = []; + + if(env('cache')) { + $options['cache'] = app()->storagePath() . 'cache'; + } + + self::$twig = new Environment($loader, $options); $this->loadHelperFunctions();