RouterRegister Help

Other Attributes

Other attributes that can be applied.

DefaultValue

Defines a default value for a parameter when the route does not contain a value.

Use On

Action

Cardinality

*

Parameter

Type

Description

Default

parameter

string

Name of the parameter

<Required>

value

int|string

The default value

<Required>

Fallback

Defines a fallback route that is attempted if no other routes in a group match.

Use On

Action

Cardinality

?

Host

Defines a host that all routes in a class are valid for.

When used at the class level it applies to all routes in the class.

Use On

Action | Group Enumeration | Group Enumeration Case | Route Enumeration

Cardinality

*

Parameter

Type

Description

Default

host

string

The host the route is valid for

<Required>

Middleware

Defines a middleware to apply the route or, if the `disable` parameter is `true`, an ancestor group middleware that should not be invoked.

When used at the class level it applies to all routes in the class.

See Also: Defining Middleware Attributes

Use On

Action | Group Enumeration | Group Enumeration Case | Route Enumeration

Cardinality

*

Parameter

Type

Description

Default

middleware

array|string

The middleware(s)

An array definition of middleware must use the Yiisoft\Definitions\ArrayDefinition syntax.

To use a closure as middleware, define it as a string; strings starting with 'fn' or 'function' are treated as closures.

Example:

'fn (' . MyMiddleware::class . ' $middleware) => $middleware->setValue("' . ValueEnum::acase->value . '")'

All other strings are treated "as is".

<Required>

disable

bool

Disable the parent group middleware

false

Override

Overrides another route with the same name.

Use On

Action

Cardinality

?

Last modified: 28 November 2025