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);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community