mardi 4 juin 2019

How does Laravel create a 404 view when a route is not defined

I am working through trying to understand Laravel under the hood, as personally this helps me learn and remember how something works. I cannot work out how the basic 404 works.

I have tried lots of var_dumping in the Illuminate\RoutingRouteCollection.php on 157

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;
}

It looks as if it must be the NotFoundHttpException, that outputs the 404 view, but I cannot work out how?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2QHxBii
via IFTTT

Aucun commentaire:

Enregistrer un commentaire