Last active
May 12, 2017 15:41
-
-
Save rslhdyt/72c0bc3bd6ee5d2a2c17959d7bcba1f8 to your computer and use it in GitHub Desktop.
Create table views of all registered routes in Laravel and Lumen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>"; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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