Skip to content

Instantly share code, notes, and snippets.

@rslhdyt
Last active May 12, 2017 15:41
Show Gist options
  • Save rslhdyt/72c0bc3bd6ee5d2a2c17959d7bcba1f8 to your computer and use it in GitHub Desktop.
Save rslhdyt/72c0bc3bd6ee5d2a2c17959d7bcba1f8 to your computer and use it in GitHub Desktop.
Create table views of all registered routes in Laravel and Lumen
<?php
// FOR LARAVEL
Route::get('route-list', function() {
$routeCollection = Route::getRoutes();
echo "<table style='width:100%'>";
echo "<tr>";
echo "<td width='10%'><h4>HTTP Method</h4></td>";
echo "<td width='10%'><h4>Route</h4></td>";
echo "<td width='80%'><h4>Corresponding Action</h4></td>";
echo "</tr>";
foreach ($routeCollection as $value) {
echo "<tr>";
echo "<td>" . $value->getMethods()[0] . "</td>";
echo "<td>" . $value->getPath() . "</td>";
echo "<td>" . $value->getActionName() . "</td>";
echo "</tr>";
}
echo "</table>";
});
<?php
// FOR LUMEN
$app->get('route-list', function() use ($app) {
$routeCollection = $app->getRoutes();
echo "<table style='width:100%'>";
echo "<tr>";
echo "<td width='10%'><h4>HTTP Method</h4></td>";
echo "<td width='10%'><h4>Route</h4></td>";
echo "</tr>";
foreach ($routeCollection as $key => $value) {
echo "<tr>";
echo "<td>" . $value['method'] . "</td>";
echo "<td>" . $value['uri'] . "</td>";
echo "</tr>";
}
echo "</table>";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment