why?? "Unable to prepare route ... for serialization. Uses Closure."

Posted 3 years ago by andy

When I do "route:clear" I get this error:

Unable to prepare route [language/{lang}] for serialization. Uses Closure.

The route that is causing this is:

Route::get('/language/{lang}', function ($lang) {
    Session::put('locale', $lang);
    return Redirect::back();

I'm trying to understand this problem, my questions are:

  1. Why is this happening? Meaning, I based that route off the docs and I can't seem to understand why would a documented suggestion cause an error.

  2. What is a solution or even does anybody have a link to share?


Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.