直接代碼:
以下代碼同樣用于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);
}
}
}