Support the ongoing development of Laravel.io →
Cache Blade
Last updated 1 year ago.
0

I created some middleware to do this in sandbox environment:

<?php namespace App\Http\Middleware;
/**************************************************************************************
 * These class is responsible for clearing the Laravel cache in sandbox environments
 *
 */
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Foundation\Application;

/**
 * ClearLaravelCache
 * Just redirects to next closure, but will clear Laravel cache in sandbox environments
 * 
 * @param request The request object.
 * @param $next The next closure.
 * @return redirects to the secure counterpart of the requested uri.
*/
class ClearLaravelCache implements Middleware
{
	protected $app;
	
	public function __construct(Application $app)
	{
		$this->app = $app;
	}
	
	public function handle($request, Closure $next)
	{
		if (env('APP_ENV') === 'sandbox') {
			$cachedViewsDirectory=app('path.storage').'/framework/views/';
			$files = glob($cachedViewsDirectory.'*');
			foreach($files as $file) {
				if(is_file($file)) {
					@unlink($file);
				}
			}
		}
	
		return $next($request);
	}
	
}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

dcheslow1 dcheslow1 Joined 24 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.