To return a view without a closure, you add it to the relevant controller.
Route::get('test', testController@index);
// in controller
public function index()
{
return view('test');
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
one of the errors: Unable to prepare route [api/user] for serialization. Uses Closure.
or Unable to prepare route [/] for serialization. Uses Closure. etc
I could run the command by commenting this routes but now I get a 404 at welcome screen:
Route::get('/', function () {
return view('welcome');
});
Route::get('csstest', function () {
return view('csstest');
});
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
So how do you return a view without a closure?
Please or to participate in this conversation.