master

laravel/framework

Last updated at: 29/12/2023 09:24

RouteFileRegistrar.php

TLDR

This file contains the RouteFileRegistrar class, which is responsible for registering routes from a given routes file.

Classes

RouteFileRegistrar

This class is responsible for registering routes from a given routes file. It has the following methods:

  • __construct(Router $router): Constructor method that creates a new instance of RouteFileRegistrar. Accepts a Router instance as a parameter.
  • register($routes): Method that requires the given routes file. Accepts the path to the routes file as a parameter.
<?php

namespace Illuminate\Routing;

class RouteFileRegistrar
{
    /**
     * The router instance.
     *
     * @var \Illuminate\Routing\Router
     */
    protected $router;

    /**
     * Create a new route file registrar instance.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    public function __construct(Router $router)
    {
        $this->router = $router;
    }

    /**
     * Require the given routes file.
     *
     * @param  string  $routes
     * @return void
     */
    public function register($routes)
    {
        $router = $this->router;

        require $routes;
    }
}