Set cache option in .env

This commit is contained in:
Maarten 2020-02-13 19:09:39 +01:00
parent 2e08a63aa7
commit 40e64ef9b7
4 changed files with 18 additions and 7 deletions

2
.env
View file

@ -1,2 +0,0 @@
DEBUG=true
VIEW_CACHE=true

5
.gitignore vendored
View file

@ -1,4 +1,5 @@
.idea .env
storage/cache
vendor vendor
resources/cache .idea

View file

@ -77,6 +77,14 @@ class BootstrapFactory {
return "../resources/"; return "../resources/";
} }
/**
* @return string
*/
public function storagePath()
{
return "../storage/";
}
/** /**
* @return ViewEngine * @return ViewEngine
*/ */

View file

@ -26,9 +26,13 @@ class ViewEngine extends AppFactory {
{ {
$loader = new FilesystemLoader(app()->resourcePath() . 'views'); $loader = new FilesystemLoader(app()->resourcePath() . 'views');
self::$twig = new Environment($loader, [ $options = [];
//'cache' => app()->resourcePath() . 'cache'
]); if(env('cache')) {
$options['cache'] = app()->storagePath() . 'cache';
}
self::$twig = new Environment($loader, $options);
$this->loadHelperFunctions(); $this->loadHelperFunctions();