首页 > 解决方案 > Laravel如何禁用/删除路由缓存

问题描述

我正忙于将 Laravel 5.4 升级到 5.8 并收到错误无法为序列化准备路由 xxx。使用 s 闭包。

我有很多闭包,web.php不打算重构它。

是否有可能以及如何删除/禁用路由缓存?

错误:

   LogicException  : Unable to prepare route [login] for serialization. Uses Closure.

  at C:\App\lv-5-8\vendor\laravel\framework\src\Illuminate\Routing\Route.php:917
    913|      */
    914|     public function prepareForSerialization()
    915|     {
    916|         if ($this->action['uses'] instanceof Closure) {
  > 917|             throw new LogicException("Unable to prepare route [{$this->uri}] for seriali
zation. Uses Closure.");
    918|         }
    919|
    920|         $this->compileRoute();
    921|

  Exception trace:

  1   Illuminate\Routing\Route::prepareForSerialization()
      C:\App\lv-5-8\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteCacheCommand.
php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      C:\App\lv-5-8\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

  Please use the argument -v to see more details.

标签: laravel-5

解决方案


在我composer.json那里有php artisan optimize在 Laravel 5.6 中被弃用的。所以我删除了它并且它有效。


推荐阅读