Laravel 2: execute route: cache: LogicException laravel5 routes support caching. Run the following command:
Php artisan route: cache
After the execution is completed, the following error is reported:
Route cache cleared! [LogicException] Unable to prepare route [/] for serialization. Uses Closure.
The error message of this exception is already very clear: in the closure, the routing cache cannot be performed. Now there are two methods:
① If you want to continue using the closure, you can only discard the route cache (at least I have no other method at present, if you have one, please tell me ).
② That is, in the routing, that is, in route. php, do not use the closure method, and change all to the controller.
Example:
// The Route with the previous error: get ('/', function () {return veiw ('Welcome ') ;}); // after modification, route: get ('/', 'homecontroller @ index ');
Now let's get it done. Execute php artisan route again: cache to view the success message:
Route cache cleared! Routes cached successfully!