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

Mid / Sen. Software Engineer
Clearwater, FL
ShineOn
Remote PHP / Laravel Developer
Remote
SpringboardVR
Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
Senior Laravel Developer
Leidseplein, Amsterdam
Orderchamp.com
PHP Developer
Remote
X-Team
Senior Laravel Developer (Canada and India)
London, Ontario, Canada
Factory Bucket Inc.
Laravel, PHP, PostgreSQL, Neo4J Developer
Pune, India (intern in Denver, CO)
Life AI