class Route

Methods

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

Constructor for the Route class.

array
getMethods()

Get the HTTP methods supported by the route.

callable|string
getHandler()

Get the handler for the route.

name(string $name)

Set the name of the route.

middleware(string $middleware)

Add a middleware to the route.

void
mergeGroupMiddlewares(RouteGroup $group)

Merge the middlewares from a route group.

array
getMiddlewares()

Get the list of middlewares applied to the route.

namespace(string|null $namespace)

Set the namespace for the route.

string|null
getNamespace()

Get the namespace of the route.

string|null
getName()

Get the name of the route.

setGroup(RouteGroup $group)

Set the route group the route belongs to.

RouteGroup|null
getGroup()

Get the route group the route belongs to.

setPath(string $path)

Set the path of the route.

string
getPath()

Get the path of the route.

setParams(array $params)

Set the parameters for the route.

array
getParams()

Get the parameters for the route.

string
toUrl()

Generate the URL for the route.

Details

at line 57
__construct(array $methods, string $path, callable|string $handler)

Constructor for the Route class.

Parameters

array $methods

The HTTP methods supported by the route.

string $path

The path of the route.

callable|string $handler

The handler for the route.

at line 68
array getMethods()

Get the HTTP methods supported by the route.

Return Value

array

The HTTP methods supported by the route.

at line 77
callable|string getHandler()

Get the handler for the route.

Return Value

callable|string

The handler for the route.

at line 87
Route name(string $name)

Set the name of the route.

Parameters

string $name

The name of the route.

Return Value

Route

The current Route instance.

at line 98
Route middleware(string $middleware)

Add a middleware to the route.

Parameters

string $middleware

The middleware to add.

Return Value

Route

The current Route instance.

at line 109
void mergeGroupMiddlewares(RouteGroup $group)

Merge the middlewares from a route group.

Parameters

RouteGroup $group

The route group to merge middlewares from.

Return Value

void

at line 118
array getMiddlewares()

Get the list of middlewares applied to the route.

Return Value

array

The list of middlewares.

at line 128
Route namespace(string|null $namespace)

Set the namespace for the route.

Parameters

string|null $namespace

The namespace to set.

Return Value

Route

The current Route instance.

at line 138
string|null getNamespace()

Get the namespace of the route.

Return Value

string|null

The namespace of the route.

at line 147
string|null getName()

Get the name of the route.

Return Value

string|null

The name of the route.

at line 156
setGroup(RouteGroup $group)

Set the route group the route belongs to.

Parameters

RouteGroup $group

The route group to set.

at line 165
RouteGroup|null getGroup()

Get the route group the route belongs to.

Return Value

RouteGroup|null

The route group the route belongs to.

at line 174
setPath(string $path)

Set the path of the route.

Parameters

string $path

The path to set.

at line 183
string getPath()

Get the path of the route.

Return Value

string

The path of the route.

at line 192
setParams(array $params)

Set the parameters for the route.

Parameters

array $params

The parameters to set.

at line 201
array getParams()

Get the parameters for the route.

Return Value

array

The parameters for the route.

at line 211
string toUrl()

Generate the URL for the route.

Return Value

string

The generated URL.

Exceptions

RuntimeException