vendredi 18 janvier 2019

Is there any other way to print or get all the routes of my laravel app?

I am trying to test all my routes if they are returning status code 200. To do that, I am currently doing something like the below code:

I have searched for this and many of the solutions are given like: $allRoutes = Route::getRoutes(); but unfortunately its not working for me. It's showing method not found. getPath() and getMethod() also showing the same result.

 $routesCollection = [
        'routes goes here',
    ];

    foreach ($routesCollection as $route) {
        $response = $this->call('GET', $route);
        $status = $response->getStatusCode();
        echo $route, ': ', $status, " \n";

        if ($status == 302) {
            $response->assertRedirect('/');
        } else {
            echo 'Something went wrong';
        }
    }

Aucun commentaire:

Enregistrer un commentaire