Skip to content

Instantly share code, notes, and snippets.

@noherczeg
Last active December 29, 2015 12:09
Show Gist options
  • Save noherczeg/7668928 to your computer and use it in GitHub Desktop.
Save noherczeg/7668928 to your computer and use it in GitHub Desktop.
Laravel Routing Map with most relevant Routing informations
<?php
// routes.php
use Illuminate\Support\Facades\Route;
Route::get('/', function()
{
$routes = [];
foreach (Route::getFacadeRoot()->getRoutes()->all() as $route) {
$praction = explode("@", $route->getAction());
$routes[] = [
"controller" => (strlen($praction[0]) == 0) ? $route->getAction() : $praction[0],
"action" => (isset($praction[1])) ? $praction[1] : null,
"params" => $route->getParameters(),
"path" => $route->getPath(),
"method" => $route->getMethods()[0]
];
}
dd($routes);
});
/**
* Example results:
*
* 0 =>
* array (size=5)
* 'controller' => null
* 'action' => null
* 'params' =>
* array (size=0)
* empty
* 'path' => string '/' (length=1)
* 'method' => string 'GET' (length=3)
* 1 =>
* array (size=5)
* 'controller' => string 'UsersController' (length=19)
* 'action' => string 'index' (length=5)
* 'params' =>
* array (size=0)
* empty
* 'path' => string '/v1/users' (length=13)
* 'method' => string 'GET' (length=3)
* 2 =>
* array (size=5)
* 'controller' => string 'UsersController' (length=19)
* 'action' => string 'show' (length=4)
* 'params' =>
* array (size=1)
* 'id' => null
* 'path' => string '/v1/users/{id}' (length=18)
* 'method' => string 'GET' (length=3)
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment