Output the route:list Command as JSON in Laravel 5.8.25

Output the route:list Command as JSON in Laravel 5.8.25

The Laravel team released v5.8.25 this week with the ability to output the route:list report in JSON format and improvements for asserting view data in tests.

Please note that since v5.8.25 was released, version 5.8.26 was tagged shortly after with a revert and you should update to v5.8.26. The bulk of the most recent updates are in Laravel 5.8.25 which we highlight below.

First, you can now output the route list from the CLI as JSON:

php artisan route:list --json

[{"domain":null,"method":"GET|HEAD","uri":"\/","name":null,"action":"Closure","middleware":"web"},
{"domain":null,"method":"GET|HEAD","uri":"api\/user","name":null,"action":"Closure","middleware":"api,auth:api"}]

Next, tests can assert all the view data by exposing the View::gatherData() method as public:

$response = $this->get('some/request');

$response->original->gatherData();

// Example assertion
$this->assertArrayHasKey('someKey', $response->original->gatherData());

A longstanding issue was resolved by Dries Vints for passing column parameters on the paginate method:

DB::table('posts')->paginate(5, ['title', 'content']);

Check out Pull Request #28937 for more details on the test coverage added and the code change.

You can see the whole diff between 5.8.24 and 5.8.25 on GitHub. We will include release notes once the changlog has been updated, but GitHub is always the most accurate place to see releases.


Filed in: News / Releases


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Full Stack or Back-End Developer
Alexandria, VA; Tallahassee, FL; Orlando, FL
Marketing for Change
Full Stack Software Engineer
Atlanta, GA or Remote
Voxie
Laravel/PHP Developer
Chicago, IL
Neon One
Software Engineer, Web Applications
Vaughan, ON, Canada
Blast Motion
Contract Services Software Engineer (Laravel | Vue | Tailwind)
Remote
Riverbed Technology
Senior Laravel Developer
Wilmington, NC
GE Software Inc.
Senior Full Stack Developer (PHP | Vue | DDD)
Charleston, SC
MassageBook