laravel-modules: Routes defined in routes/web.php not working anymore

Below routes defined in Laravel’s default routing file routes/web.php are not working from the browser, but can be seen in route:list.

The same block of code defined in any routes.php under any module is working fine.

Route::group(['prefix' => 'api', 'namespace' => 'App\Http\Controllers'], function () {
    Route::get('/world/countries', 'API\WorldController@countrylist')->name('API.world.countrylist');
    Route::get('/world/regions', 'API\WorldController@regionlist')->name('API.world.regionlist');
    Route::get('/world/cities', 'API\WorldController@citylist')->name('API.world.citylist');
});

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 38 (16 by maintainers)

Most upvoted comments

Dunno but have you activated the modules? I had to do that after upgrade from Laravel 5 to 6.

php artisan module:enable <Module>

Hi, I’m facing this problem too. One of my Module api.php files suddenly stopped being scanned for routes. I’m not sure why and how to solve it. Once I solve it, I’ll let you guys know.

Solution: It was something or a combination of the following: namespace “\Modules\YourModule” vs "Modules\YourModule" I was inserting into the app.php, $defer = true/false in YourModuleServiceProvider and php artisan module:dump, php artisan optimize, composer dump

It’s not specific, but if you experience this problem, maybe one of the things above will help.