Русское сообщество разработки на PHP-фреймворке Laravel.
Ты не вошёл. Вход тут.
На базе Middleware
Что требует включения Middleware в /bootstrap/app.php
/app/Http/Middleware/ClearViewCacheMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
//use Laravel\Lumen\Application;
class ClearViewCacheMiddleware
{
protected $app;
// public function __construct(Application $app)
// {
// $this->app = $app;
// }
public function handle($request, Closure $next)
{
$cachedViewsDirectory=storage_path().'/framework/views/';
$files = glob($cachedViewsDirectory.'*');
foreach($files as $file) {
if(is_file($file)) {
unlink($file);
}
}
return $next($request);
}
}
/bootstrap/app.php
$app->middleware([
....
Laravel\Lumen\Http\Middleware\VerifyCsrfToken::class,
Не в сети
Hello,
To include your custom ClearViewCacheMiddleware in your Lumen application's bootstrap/app.php file, you'll need to add it to the middleware stack. Here's how you can do it:
First, ensure that the middleware file is correctly placed in your project directory: /app/Http/Middleware/ClearViewCacheMiddleware.php.
Then, in your bootstrap/app.php file, add the following line to the $app->middleware() array to include your custom middleware:
php
$app->middleware([
// Other middlewares...
App\Http\Middleware\ClearViewCacheMiddleware::class,
Laravel\Lumen\Http\Middleware\VerifyCsrfToken::class,
]);
This will ensure that the ClearViewCacheMiddleware is executed with each request, and it will clear the cached views as defined in your middleware class.
Не в сети