A method to view your Laravel routes with PHP code that is an alternative to the command php artisan route:list --except-vendor
.
In this post the routes will be displayed in a HTML table.
getRoutes will return all routes in the collection as an array
$routes = Route::getRoutes();
Then you can loop over each route and get specific data by accessing its keys
foreach ($routes as $value) { $value->methods()[0]; $value->uri(); $value->getName(); $value->getActionName(); }
Integrate this into a table for easy examination
echo "<div class='table-responsive'>"; echo "<table class='table table-bordered'>"; echo "<tr>"; echo "<td><h4>HTTP Method</h4></td>"; echo "<td><h4>Route</h4></td>"; echo "<td><h4>Name</h4></td>"; echo "<td><h4>Action</h4></td>"; echo "</tr>"; foreach ($routes as $value) { echo "<tr>"; echo "<td>" . $value->methods()[0] . "</td>"; echo "<td>" . $value->uri() . "</td>"; echo "<td>" . $value->getName() . "</td>"; echo "<td>" . $value->getActionName() . "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>";