直接代码:
以下代码同样用于lumen
use Illuminate\Http\Request;
use App\Core\Router;
class TestController
{
public function getRouter() {
$result = [];
$routeCollection = \Route::getRoutes();
foreach ($routeCollection as $row) {
if ($row['uri'] == "/") {
continue;
}
unset($row['action']);
if (!isset($result[$row['uri']])) {
$result[$row['uri']] = $row;
}
}
foreach ($result as $row1) {
print_r($row1);
}
}
}