通过提供 URL,我想知道是否有任何方法可以确定该 URL 是否存在于我的 Laravel 应用程序中(与想要检查外部 URL 的“如何通过 Laravel 检查 URL 是否存在? ”相比)?
我尝试了这个,但它总是告诉我网址不匹配:
$routes = \Route::getRoutes();
$request = \Request::create('/exists');
try {
$routes->match($request);
// route exists
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e){
// route doesn't exist
}
Run Code Online (Sandbox Code Playgroud)