【发布时间】:2019-10-19 22:20:31
【问题描述】:
我正在努力了解 Laravel 的底层,因为这有助于我学习和记住某些东西是如何工作的。我无法弄清楚基本的 404 是如何工作的。
我在 157 的 Illuminate\RoutingRouteCollection.php 中尝试了很多 var_dumping
public function match(Request $request)
{
$routes = $this->get($request->getMethod());
// First, we will see if we can find a matching route for this current request
// method. If we can, great, we can just return it so that it can be called
// by the consumer. Otherwise we will check for routes with another verb.
$route = $this->matchAgainstRoutes($routes, $request);
if (! is_null($route)) {
return $route->bind($request);
}
// If no route was found we will now check if a matching route is specified by
// another HTTP verb. If it is we will need to throw a MethodNotAllowed and
// inform the user agent of which HTTP verb it should use for this route.
$others = $this->checkForAlternateVerbs($request);
if (count($others) > 0) {
return $this->getRouteForMethods($request, $others);
}
throw new NotFoundHttpException;
}
看起来一定是 NotFoundHttpException,输出 404 视图,但我不知道怎么做?
【问题讨论】:
标签: laravel laravel-5 laravel-blade