I have installed laravel 7 in my local server. When I run php artisan route:cache command then laravel return error:
LogicException
Unable to prepare route [api/user] for serialization. Uses Closure.
This problem was not in previous versions of the framework.
@devmansurov
When route has closures you can not cache route so you need to map with controller action
This problem was not in previous versions of the framework.
Closure routes were never supported so this definitely was.
I am facing this problem with laravel 7 from laravel5.3. Please help me.
This issue still exists, even using a controller method didn't help at all. Laravel still throws the same error
route/api. Then comment this:
//Route::middleware('auth:api')->get('/user', function (Request $request) {
// return $request->user();
//});
In Laravel 8 it'll be possible to cache routes using closures.
I have same issue ( laravel 7.23.2 ), after run php artisan optimize then laravel return error
Unable to prepare route [/] for serialization. Uses Closure.
My web root
Route::get('/', function () {
return view('welcome');
});
Going to lock this to prevent more "I have this too" comments.