Skip to content

Instantly share code, notes, and snippets.

@xtrasmal
Last active May 27, 2017 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtrasmal/d4f2d1857e221a5ce9d69f1f038b5860 to your computer and use it in GitHub Desktop.
Save xtrasmal/d4f2d1857e221a5ce9d69f1f038b5860 to your computer and use it in GitHub Desktop.
Laravel Route table command
<?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