How I can disable templates caching in development mode?

0 votes
Everytime when I change something in templates I have to clear cache manually. Is there some way to disable templates caching in development mode?
Apr 6 in Laravel by kartik
• 11,290 points
21 views

1 answer to this question.

0 votes

Hii @kartik,

Create a new middleware, add to 'web' $middlewareGroups in Kernel.php. This will call the artisan command to clear all compiled view files.

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_ENV') === 'local') {
            Artisan::call('view:clear');
        }

        return $next($request);
    }
}

Thank You!!

answered Apr 6 by Niroj
• 22,790 points

Related Questions In Laravel

0 votes
1 answer

How can we Disable CSRF Laravel?

Hello, You can disable CSRF Laravel from the App/Http/Kernel.php file ...READ MORE

answered Mar 19 in Laravel by Niroj
• 22,790 points
47 views
0 votes
1 answer

How can we generate migration in Laravel?

Hello, Migrations are like version control for your database, ...READ MORE

answered Mar 19 in Laravel by Niroj
• 22,790 points
29 views
0 votes
1 answer

How to delete or clear caching in Laravel?

Hey @kartik, There are many commands to clear ...READ MORE

answered Mar 20 in Laravel by Niroj
• 22,790 points
64 views
0 votes
1 answer

How can we use the custom table in Laravel?

Hey, We can easily use custom table in ...READ MORE

answered Mar 20 in Laravel by Niroj
• 22,790 points
36 views
0 votes
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,790 points
434 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,790 points
62 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 22,790 points
64 views
0 votes
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 22,790 points
151 views
0 votes
1 answer

How to enable or disable maintenance mode in Laravel?

Hii, We have to use the following artisan ...READ MORE

answered Mar 24 in Laravel by Niroj
• 22,790 points
159 views
0 votes
1 answer

What is middleware? How can we register middeleware in Laravel?

Middleware acts as a bridge between a ...READ MORE

answered Mar 18 in Laravel by Niroj
• 22,790 points
101 views