Created
August 25, 2017 10:46
-
-
Save xtrasmal/c6cfb4d0e150a2e31c8a1dcb46f7bbdc to your computer and use it in GitHub Desktop.
RouteTable command for a nice list of laravel routes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Console\Commands; | |
use Illuminate\Routing\Route; | |
use Illuminate\Foundation\Console\RouteListCommand; | |
class RouteTable extends RouteListCommand | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $name = 'route:table'; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $description = 'Table of all registered routes'; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected $headers = ['method', 'uri', 'name', 'controller', 'action']; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function getRouteInformation(Route $route) | |
{ | |
$actions = explode('@',$route->getActionName()); | |
return $this->filterRoute([ | |
'method' => implode('|', $route->methods()), | |
'uri' => $route->uri(), | |
'name' => is_string($route->getName()) ? "<fg=green>{$route->getName()}</>" : "-", | |
'controller' => isset($actions[0]) ? "<fg=cyan>{$actions[0]}</>" : "-", | |
'action' => isset($actions[1]) ? "<fg=red>{$actions[1]}</>" : "-" | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment