0

I have started working in a existing laravel project, I found all the routes placed in routes/web.php as usual. But When I declare a new route it does not work even not found on artisan route:list command.

So what I've tried so far is finding out how existing routes are working, for that I just deleted some routes from existing routes/web.php file, But I was just wondered finding it has no effect over the project. all the deleted routes still redirects to specified methods of the controllers and all the functionalities are working fine. so it looks like there is another file to place the routes instead of default web.php

I have cleared all the caches like

php artisan config:cache
php artisan cache:clear
php artisan view:clear

all the routes on web.php are as below

Route::group(['middleware' => ['auth']], function() {

//all routes are declared here like
Route::get('/', 'HomeController@index'); //example route
});

So is there any way to find out the route file working behind the scene?

Or is it really possible to change the default path of route file then routes/web.php?

Moshiur
  • 659
  • 6
  • 22
  • 1
    Does this help ? https://stackoverflow.com/questions/37878951/how-to-clear-route-caching-on-server-laravel-5-2-37 – nice_dev Feb 01 '20 at 09:08

2 Answers2

0

You've cleared a number of caches, but not your route cache.

Try running php artisan route:clear to clear your route cache.

Your routes are cached after you run php artisan route:cache, this is sometimes included in your composer.json scripts so can occur without you even being aware.

James
  • 15,754
  • 12
  • 73
  • 91
0

There is a file which serves for all routes settings app/Providers/RouteServiceProvider.php. It has method map() where it binds both routes files – web and API:

    public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

    }

    protected function mapWebRoutes()
    {
        Route::middleware('web')
             ->namespace($this->namespace)
             ->group(base_path('routes/web.php'));
    }

    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }