-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.0]route:cache with Closure problem #7319
Comments
Yep, that's the expected behaviour. |
Laravel's source code: /**
* Prepare the route instance for serialization.
*
* @return void
*
* @throws LogicException
*/
public function prepareForSerialization()
{
if ($this->action['uses'] instanceof Closure)
{
throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
}
unset($this->container);
unset($this->compiled);
} |
but ,when the app has some closure route,it means cant route cache? |
Basically, you cannot use route caching at all if you have closures in your routes. Selective caching would defeat the object. |
ok,thanks,so I will change code to not use closure route at all |
It is possible, with a little creativity, to serialize a Closure. The code should be modified to allow this. I might have to submit a PR for it |
AFAIK, taylor tried it before and found out that having to serialize and unserialize closure reduce the performance that you could possibly gain from using route caching. |
If you're not using any api func. , you can comment |
Old thread but those are just sample routes. Delete them. This is covered in the docs. |
command artisan route:cache
when met closure route:
it will fail with
The text was updated successfully, but these errors were encountered: