Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andy's avatar
Level 8

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

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?

Thanks!

0 likes
2 replies

Please or to participate in this conversation.