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

kevin73's avatar

Unable to prepare route [estimates] for serialization. Uses Closure.

Hi, someone can help me ? how to fix it ?

routes/web.php

Route::get('/', 'DashboardController@index');
Route::get('/calendar','FullCalendarController@index');

/* Vuejs */
Route::get('/estimates', function () {
    return view('estimate.index');
});

Route::group(['prefix' => 'api/'], function () {
    Route::resource('estimates', 'estimateController');
});

when i run : php artisan optimize i get like error message :

Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!

   LogicException  : Unable to prepare route [estimates] for serialization. Uses Closure.

  at /home/paranoid73/public/balbine-dash/vendor/laravel/framework/src/Illuminate/Routing/Route.php:917
    913|      */
    914|     public function prepareForSerialization()
    915|     {
    916|         if ($this->action['uses'] instanceof Closure) {
  > 917|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    918|         }

Thank you in advance

0 likes
2 replies
Nakov's avatar

@kevin73 so the error suggests that you don't use closure for your route but a controller action instead.

So this:

Route::get('/estimates', function () {
    return view('estimate.index');
});

can be replaced by this:

Route::get('/estimates', 'EstimatesController@index`);

of course you will need an EstimatesController to be created. Don't use this one : estimateController as it will override the action.

Please or to participate in this conversation.