class RouteGroup

Methods

__construct(string $prefix = '', RouteGroup|null $parent = null)

Constructor for the RouteGroup class.

RouteGroup|null
getParent()

Get the parent route group.

string
fullPrefix()

Get the full prefix for the route group, including parent prefixes.

string
getPrefix()

Get the prefix for the route group.

array
getRoutes()

Get the list of routes in the group.

addRoute(string|array $methods, string $path, callable|string $handler)

Add a route to the group.

get(string $path, callable|string $handler)

Add a GET route to the group.

post(string $path, callable|string $handler)

Add a POST route to the group.

patch(string $path, callable|string $handler)

Add a PATCH route to the group.

put(string $path, callable|string $handler)

Add a PUT route to the group.

head(string $path, callable|string $handler)

Add a HEAD route to the group.

delete(string $path, callable|string $handler)

Add a DELETE route to the group.

view(string $url, string $name, array $arguments = [])

Add a GET route that returns a view.

$this
middleware(string $middleware)

Add a middleware to the group.

array
getMiddlewares()

Get the list of middlewares applied to the group.

parseRoutes(null|array $routes = null)

Parse the routes in the group, applying parent middlewares and namespaces.

$this
namespace(string $namespace)

Set the namespace for the group.

Details

at line 36
__construct(string $prefix = '', RouteGroup|null $parent = null)

Constructor for the RouteGroup class.

Parameters

string $prefix

The prefix for the route group.

RouteGroup|null $parent

The parent route group, if any.

at line 46
RouteGroup|null getParent()

Get the parent route group.

Return Value

RouteGroup|null

The parent route group, or null if none exists.

at line 55
string fullPrefix()

Get the full prefix for the route group, including parent prefixes.

Return Value

string

The full prefix for the route group.

at line 72
string getPrefix()

Get the prefix for the route group.

Return Value

string

The prefix for the route group.

at line 81
array getRoutes()

Get the list of routes in the group.

Return Value

array

The list of routes in the group.

at line 93
Route addRoute(string|array $methods, string $path, callable|string $handler)

Add a route to the group.

Parameters

string|array $methods

HTTP methods (e.g., GET, POST).

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 118
Route get(string $path, callable|string $handler)

Add a GET route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 129
Route post(string $path, callable|string $handler)

Add a POST route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 140
Route patch(string $path, callable|string $handler)

Add a PATCH route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 151
Route put(string $path, callable|string $handler)

Add a PUT route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 162
Route head(string $path, callable|string $handler)

Add a HEAD route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 173
Route delete(string $path, callable|string $handler)

Add a DELETE route to the group.

Parameters

string $path

The route path.

callable|string $handler

The route handler.

Return Value

Route

The created route instance.

at line 185
Route view(string $url, string $name, array $arguments = [])

Add a GET route that returns a view.

Parameters

string $url

The URL of the route.

string $name

The name of the view.

array $arguments

Optional arguments to pass to the view.

Return Value

Route

The created route instance.

at line 197
$this middleware(string $middleware)

Add a middleware to the group.

Parameters

string $middleware

The middleware to add.

Return Value

$this

The current RouteGroup instance.

at line 207
array getMiddlewares()

Get the list of middlewares applied to the group.

Return Value

array

The list of middlewares.

at line 216
parseRoutes(null|array $routes = null)

Parse the routes in the group, applying parent middlewares and namespaces.

Parameters

null|array $routes

The routes to parse. Defaults to the group's routes.

at line 241
$this namespace(string $namespace)

Set the namespace for the group.

Parameters

string $namespace

The namespace to set.

Return Value

$this

The current RouteGroup instance.