title: Laravel - Error "Unable to prepare route [/] for serialization. Uses Closure."
body: <p>I'm new to Laravel and now i manage project that was left by someone.</p>
  
  <p>i try to add a function to <strong>API</strong>, what i edit :</p>
  
  <p>1) Add a Method :</p>
  
  <p><code>myproject/app/Http/Controllers/Api/ArticleController.php</code></p>
  
  <p>2) Add <strong>Routes</strong> to controler :</p>
  
  <p><code>myprojectmyproject/routes/api.php</code></p>
  
  <p>However, when i try to run <code>php artisan route:cache</code> i got below error :</p>
  
  <blockquote>
    <blockquote>
      <p><strong>Route cache cleared! \n
      LogicException  : Unable to prepare route [/] for serialization. Uses Closure.</strong></p>
    </blockquote>
  </blockquote>
  
  <p>my route file, <strong>myproject/routes/api.php</strong> :</p>
  
  <pre><code>Route::group (['prefix' =&gt; 'v1', 'middleware' =&gt; 'ValidateHeaderSignature'], function() {
  
      Route::group(['prefix' =&gt; 'auth'], function() {
          Route::post('/login', 'Api\AuthController@login');
          Route::post('/register', 'Api\AuthController@register');
          Route::post('/login-social-media', 'Api\AuthController@loginSocialMedia');
          Route::post('/forgot-password', 'Api\AuthController@forgotPassword');        
          Route::group(['middleware' =&gt; 'jwt.auth'], function() {
              Route::patch('/change-password', 'Api\AuthController@changePassword');
              Route::post('/logout', 'Api\AuthController@logout');
          });
      });
  
  
      Route::group(['prefix' =&gt; 'foundation-donate'], function() {
          Route::get('/', 'Api\FoundationDonateController@index');
      });
  
      Route::group(['prefix' =&gt; 'greeting-chat'], function() {
          Route::get('/', 'Api\GreetingChatController@index');
      });
  
      Route::group(['prefix' =&gt; 'prayer-time'], function () {
          Route::get('/', 'Api\PrayerTimeController@index');
          Route::get('/montly', 'Api\PrayerTimeController@getMontlyPrayerTimes');
      });
  
      Route::group(['prefix' =&gt; 'asmaul-husna'], function () {
          Route::get('/', 'Api\AsmaulHusnaController@index');
      });
  
  
      Route::group(['prefix' =&gt; 'guidance'], function () {
          Route::get('/zikir', 'Api\GuidanceController@zikirGuidances');
          Route::get('/prayer', 'Api\GuidanceController@prayerGuidances');
      });
  
  
      Route::group(['prefix' =&gt; 'duas'], function () {
          Route::get('/', 'Api\DuasController@index');
          Route::get('/index', 'Api\DuasController@index');
          Route::get('/all', 'Api\DuasController@allPrayers');
          Route::get('/category/{category}', 'Api\DuasController@category');
          Route::get('/show/{id}', 'Api\DuasController@show');
      });
  
      Route::group(['prefix' =&gt; 'zakat'], function () {
          Route::get('/', 'Api\ZakatController@index');
          Route::get('/index', 'Api\ZakatController@index');
          Route::get('/all', 'Api\ZakatController@allPrayers');
          Route::get('/category/{category}', 'Api\ZakatController@category');
          Route::get('/show/{id}', 'Api\ZakatController@show');
      });
  
      Route::group(['prefix' =&gt; 'playlist'], function () {
          Route::get('/zikir', 'Api\PlaylistSongController@playlistZikir');
          Route::get('/shalawat', 'Api\PlaylistSongController@playlistShalawat');
          Route::get('/duas', 'Api\PlaylistSongController@playlistDuas');
          Route::get('/murottal', 'Api\PlaylistSongController@playlistMurottal');
          Route::get('/songs', 'Api\PlaylistSongController@playlistSongs');
      });
  
      Route::group(['prefix' =&gt; 'dzikir'], function() {
          Route::get('/primary', 'Api\DzikirController@primaryDzikir');
          Route::get('/my-dzikir', 'Api\DzikirController@myDzikir');
          Route::get('/categories', 'Api\DzikirController@dzikirCategories');
  
          Route::group(['middleware' =&gt; 'jwt.auth'], function() {
              Route::get('/point-total', 'Api\DzikirController@pointTotal');
              Route::get('/histories', 'Api\DzikirController@histories');
              Route::get('/total-dzikir-history', 'Api\DzikirController@totalDzikirHistory');
              Route::post('/post-dzikir', 'Api\DzikirController@postDzikir');
          });
      });
      Route::group(['prefix' =&gt; 'sadaqah'], function() {
          Route::group(['middleware' =&gt; 'jwt.auth'], function() {
              Route::get('/histories', 'Api\DzikirController@sadaqahHistories');
          });
      });
      Route::group(['prefix' =&gt; 'article'], function() {
          Route::get('/', 'Api\ArticleController@index');
          Route::get('/daily-reflection', 'Api\ArticleController@getDailyReflection');
          Route::get('/get-random', 'Api\ArticleController@getRandom');
      });
  
  
      Route::group(['prefix' =&gt; 'notification'], function() {
          Route::get('/quote', 'Api\NotificationController@prayerQuotes');
      });
  
  
      Route::group(['prefix' =&gt; 'user', 'middleware' =&gt; 'jwt.auth'], function() {
          Route::get('/show', 'Api\UserController@show');
          Route::patch('/update-profile', 'Api\UserController@update');
      });
      Route::group(['prefix' =&gt; 'master'], function() {
          Route::get('/location', 'Api\MasterController@location');
      });
  
  });
  </code></pre>
  
  <p>if i got error because of <a href="https://stackoverflow.com/questions/45266254/laravel-unable-to-prepare-route-for-serialization-uses-closure"><strong>Uses Closure</strong></a>, why previous developer can populate route? </p>
  
  <p>by run <code>php artisan route:list</code> i can see list of route that have ever made before.</p>
  
  <p>any idea ?</p>
  
  <p>===Update, Add routes/web.php</p>
  
  <pre><code>Route::get('/', function () {
      return view('welcome');
  });
  Auth::routes(['register' =&gt; false]);
  Route::get('/home', 'HomeController@index')-&gt;name('home');
  Route::get('register/activation/{code}', 'Auth\\RegisterController@activation')-&gt;name('register.activation');
  Route::group(['prefix' =&gt; 'admin', 'middleware' =&gt; ['auth']], function() {
      Route::get('/user-apps/list-index', ['as' =&gt; 'user-apps.list-index', 'uses' =&gt; 'Admin\\UserAppsController@listIndex']);
      Route::get('/user-apps/resend-confirmation', ['as' =&gt; 'user-apps.resend-confirmation', 'uses' =&gt; 'Admin\\UserAppsController@resendConfirmation']);
      Route::resource('/user-apps', 'Admin\\UserAppsController');
      Route::get('/user/list-index', ['as' =&gt; 'user.list-index', 'uses' =&gt; 'Admin\\UserController@listIndex']);
      Route::resource('/user', 'Admin\\UserController');
      Route::get('/dzikir-playlist-category/list-index', ['as' =&gt; 'dzikir-playlist-category.list-index', 'uses' =&gt; 'Admin\\DzikirPlaylistCategoryController@listIndex']);
      Route::resource('/dzikir-playlist-category', 'Admin\\DzikirPlaylistCategoryController');
  
      Route::get('/dzikir-playlist/list-index', ['as' =&gt; 'dzikir-playlist.list-index', 'uses' =&gt; 'Admin\\DzikirPlaylistController@listIndex']);
      Route::resource('/dzikir-playlist', 'Admin\\DzikirPlaylistController');
  
      Route::get('/dzikir-playlist-homepage/list-index', ['as' =&gt; 'dzikir-playlist-homepage.list-index', 'uses' =&gt; 'Admin\\DzikirPlaylistHomepageController@listIndex']);
      Route::resource('/dzikir-playlist-homepage', 'Admin\\DzikirPlaylistHomepageController');
      Route::get('/dzikir-playlist-my-zikir/list-index', ['as' =&gt; 'dzikir-playlist-my-zikir.list-index', 'uses' =&gt; 'Admin\\DzikirPlaylistMyZikirController@listIndex']);
      Route::resource('/dzikir-playlist-my-zikir', 'Admin\\DzikirPlaylistMyZikirController');
      Route::get('/greeting-chat/list-index', ['as' =&gt; 'greeting-chat.list-index', 'uses' =&gt; 'Admin\\GreetingChatController@listIndex']);
      Route::resource('/greeting-chat', 'Admin\\GreetingChatController');
      Route::get('/foundation-donate/list-index', ['as' =&gt; 'foundation-donate.list-index', 'uses' =&gt; 'Admin\\FoundationDonateController@listIndex']);
      Route::resource('/foundation-donate', 'Admin\\FoundationDonateController');
      Route::get('/asmaul-husna/list-index', ['as' =&gt; 'asmaul-husna.list-index', 'uses' =&gt; 'Admin\\AsmaulHusnaController@listIndex']);
      Route::resource('/asmaul-husna', 'Admin\\AsmaulHusnaController');
      Route::get('/guidance/list-index', ['as' =&gt; 'guidance.list-index', 'uses' =&gt; 'Admin\\GuidanceController@listIndex']);
      Route::resource('/guidance', 'Admin\\GuidanceController');
      Route::get('/content-category/list-index', ['as' =&gt; 'content-category.list-index', 'uses' =&gt; 'Admin\\ContentCategoryController@listIndex']);
      Route::resource('/content-category', 'Admin\\ContentCategoryController');
      Route::get('/duas/list-index', ['as' =&gt; 'duas.list-index', 'uses' =&gt; 'Admin\\DuasController@listIndex']);
      Route::resource('/duas', 'Admin\\DuasController');
      Route::get('/zakat/list-index', ['as' =&gt; 'zakat.list-index', 'uses' =&gt; 'Admin\\ZakatController@listIndex']);
      Route::resource('/zakat', 'Admin\\ZakatController');
      Route::get('/quote/list-index', ['as' =&gt; 'quote.list-index', 'uses' =&gt; 'Admin\\QuoteController@listIndex']);
      Route::resource('/quote', 'Admin\\QuoteController');
      Route::get('/playlist-song-category/list-index', ['as' =&gt; 'playlist-song-category.list-index', 'uses' =&gt; 'Admin\\PlaylistSongCategoryController@listIndex']);
      Route::resource('/playlist-song-category', 'Admin\\PlaylistSongCategoryController');
      Route::get('/playlist-song/list-index', ['as' =&gt; 'playlist-song.list-index', 'uses' =&gt; 'Admin\\PlaylistSongController@listIndex']);
      Route::resource('/playlist-song', 'Admin\\PlaylistSongController');
      Route::get('/album/list-index', ['as' =&gt; 'album.list-index', 'uses' =&gt; 'Admin\\AlbumController@listIndex']);
      Route::resource('/album', 'Admin\\AlbumController');
      Route::get('/artist/list-index', ['as' =&gt; 'artist.list-index', 'uses' =&gt; 'Admin\\ArtistController@listIndex']);
      Route::resource('/artist', 'Admin\\ArtistController');
      Route::get('/article/list-index', ['as' =&gt; 'article.list-index', 'uses' =&gt; 'Admin\\ArticleController@listIndex']);
      Route::resource('/article', 'Admin\\ArticleController');
  });
  </code></pre>