RouterRegister Help

Group Attributes

Attributes used in group definitions.

Group

Use On

Route Enumeration

Cardinality

?

Defines group for a set of routes.

Parameter

Type

Description

Default

name

?string

The name prefix for the routes

<Required>

parent

?GroupInterface

The parent group

null

Cors

Use On

Group Enumeration | Group Enumeration Case | Route Enumeration

Cardinality

?

Defines CORS middleware to apply a group.

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>

Host

Use On

Action | Group Enumeration | Group Enumeration Case | Route Enumeration

Cardinality

*

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

Parameter

Type

Description

Default

host

string

The host the route is valid for

<Required>

Middleware

Use On

Action | Group Enumeration | Group Enumeration Case | Route Enumeration

Cardinality

*

Defines a middleware to apply a group.

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>

Prefix

Use On

Group Enumeration | Route Enumeration

Cardinality

?

Defines the group route prefix.

When applied to a Group Enumeration it defines a common prefix for all groups in the Enumeration.

When applied to a Group Enumeration Case it defines the prefix for that Enumeration Case.

If applied to both a Group Enumeration and a Group Enumeration Case, the Group Enumeration Case prefix is appended to the Group Enumeration prefix.

Parameter

Type

Description

Default

prefix

array|string

Route prefix definition

<Required>

Last modified: 28 November 2025