Laravel learning 2: execute route: cache to report LogicException

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.