We can show routes we are using in a Laravel application even if we did not declare them in “routes/web.php” file. For example, sometimes we declare each and every route like this.
Route::get('/', '[email protected]'); Route::get('select2', '[email protected]'); Route::get('/select2-autocomplete-ajax', '[email protected]');
But sometimes we just declare resource and every route is declared and mapped with Controller methods.
Now in the code written above we would not know what is going on unless we check Routes. There are 2 ways to get routes information.
1. Laravel Routes Facade
we can get all routes by “Route::getRoutes()”.
$routes = \Route::getRoutes();
2. Using Laravel List Command
By using this command we can list all routes on our command line.
php artisan route:list
We recommend reading Laravel Routing docs. If you face any problem, let us know in the comments. We would address it.