0

Here is the simple routing code: (i take it from official site just for example)

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

    });

    Route::get('user/profile', function () {

    });
});

Is it possible to get all routes from this group programmatically? Thank you.

SergioZhidkov
  • 371
  • 1
  • 3
  • 13
  • If shell command is enough, then you can use `php artisan route:list`. This will list all routes and the HTTP methods used to invoke it, the controllers which each route will handle and which middleware it belongs to. – JTheDev Nov 18 '16 at 06:20
  • @JTheDev Thank you for answer. Is it possible to get same information from controller? – SergioZhidkov Nov 18 '16 at 06:55
  • sorry nothing is coming to my mind. `Artisan::call('route:list') ;` is also returning 0. – JTheDev Nov 18 '16 at 07:09

1 Answers1

0

Hope, this function will help you..

In Routes.php file --

Route::get('routes', function() {

       \Artisan::call('route:list');
       echo '<pre>'; print_r(\Artisan::output());

});
Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43
Rishabh
  • 1
  • 2