Skip to content

Commit

Permalink
Merge pull request #28894 from jasonmccreary/route-list-as-json
Browse files Browse the repository at this point in the history
[5.8] Add option to output route:list as JSON
  • Loading branch information
taylorotwell committed Jun 20, 2019
2 parents 806291e + f1f144e commit 8452136
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Illuminate/Foundation/Console/RouteListCommand.php
Expand Up @@ -153,6 +153,12 @@ protected function pluckColumns(array $routes)
*/
protected function displayRoutes(array $routes)
{
if ($this->option('json')) {
$this->line(json_encode(array_values($routes)));

return;
}

$this->table($this->getHeaders(), $routes);
}

Expand Down Expand Up @@ -247,6 +253,7 @@ protected function getOptions()
return [
['columns', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Columns to include in the route table'],
['compact', 'c', InputOption::VALUE_NONE, 'Only show method, URI and action columns'],
['json', null, InputOption::VALUE_NONE, 'Output the route list as JSON'],
['method', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by method'],
['name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name'],
['path', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by path'],
Expand Down

0 comments on commit 8452136

Please sign in to comment.