Laravel 5 Clear Views Cache

前端 未结 8 1511
悲&欢浪女
悲&欢浪女 2020-12-02 07:41

I notice that Laravel cache views are stored in ~/storage/framework/views. Over time, they get to eat up my space. How do I delete them? Is there any command th

相关标签:
8条回答
  • 2020-12-02 08:32

    To answer your additional question how disable views caching:

    You can do this by automatically delete the files in the folder for each request with the command php artisan view:clear mentioned by DilipGurung. Here is an example Middleware class from https://stackoverflow.com/a/38598434/2311074

    <?php
    namespace App\Http\Middleware;
    
    use Artisan;
    use Closure;
    
    class ClearViewCache
    {
        /**
         * Handle an incoming request.
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  \Closure  $next
         * @return mixed
         */
        public function handle($request, Closure $next)
        {
            if (env('APP_DEBUG') || env('APP_ENV') === 'local') 
                Artisan::call('view:clear');
    
            return $next($request);
        }
    }
    

    However you may note that Larevel will recompile the files in the /app/storage/views folder whenever the time on the views files is earlier than the time on the PHP blade files for the layout. THus, I cannot really think of a scenario where this would be necessary to do.

    0 讨论(0)
  • 2020-12-02 08:35

    please try this below command :

    sudo php artisan cache:clear
    
    sudo php artisan view:clear
    
    sudo php artisan config:cache
    
    0 讨论(0)
提交回复
热议问题