Laravel and view caching in development — can't see changes right away

后端 未结 7 1655
情深已故
情深已故 2020-12-01 14:21

Some friends and I decided to start working on a project and we came across Laravel and thought it might be a good tool. We started using it locally to develop out some of

7条回答
  •  情深已故
    2020-12-01 14:41

    With newer versions of PHP, opcache doesn't work. This is what I use (in app/filters.php):

    App::before(function($request)
    {
        // Clear view cache in sandbox (only) with every request
        if (App::environment() == 'sandbox') {
            $cachedViewsDirectory=app('path.storage').'/views/';
            $files = glob($cachedViewsDirectory.'*');
            foreach($files as $file) {
                if(is_file($file)) {
                    @unlink($file);
                }
            }
        }
    });
    

提交回复
热议问题