RouterRegister Help

Create a Writer Object

A RouterRegister Writer object takes the internal representation of the groups and routes and transforms it into a framework specific representation. This section describes the Group and Route objects used internally. It does not describe the output as this is framework specific.

WriterInterface

A Writer object must implement WriterInterface, which defines the following methods:

Method

Parameters

Return Type

Description

setPath(string $path)

string $path

self

Sets the filepath for the output files

write(array $groups)

list<Group> $group

void

Takes the internal router configuration, an array of Group objects, and generates and writes the output files

Group Object

The Group Object has the following methods:

Method

Return Type

Description

getCors()

?MiddlewareInterface

The CORS Middleware attribute object if defined, NULL if not

Call getMiddleware() on the Middleware attribute object to get the middleware string

getDisableMiddlewares()

list<MiddlewareInterface>

List of Middleware attribute objects that disable a middleware defined in an ancestor Group

Call getMiddleware() on a Middleware attribute object to get the middleware string

getHosts()

list<Host>

List of Host attribute objects that define the hosts that the Group will respond to

Call getHost() on a Host attribute object to get the host string

getMiddlewares()

list<Middleware>

List of Middleware attribute objects apply to the Group

Call getMiddleware() on a Middleware attribute object to get the middleware string

getName()

string

The Group name

getPrefix()

?string

The Group route prefix if defined, NULL if not

getRoutes()

list<Group|Route>

Groups and Routes in the Group

hasCors()

bool

true if the Group has CORS middleware defined, false if not

hasHosts()

bool

true if the Group has hosts defined, false if not

Route Object

Method

Return Type

Description

getAction()

Middleware

A Middleware attribute object that defines the action to run if the route matches the request

Call getMiddleware() on the Middleware attribute object to get the middleware string

getDefaultValues()

list<DefaultValue>

List of parameter default values

Call getParameter() on a DefaultValue attribute object to get the parameter name

Call getValue() on a DefaultValue attribute object to get the parameter value

getDisableMiddlewares()

list<MiddlewareInterface>

List of Middleware attribute objects that disable a middleware defined in an ancestor Group

Call getMiddleware() on a Middleware attribute object to get the middleware string

getHosts()

list<Host>

List of Host attribute objects that define the hosts that the Route will respond to

Call getHost() on a Host attribute object to get the host string

getMethods()

array

List of HTTP methods that the route responds to

getMiddlewares()

list<Middleware>

List of Middleware attribute objects apply to the Route

Call getMiddleware() on a Middleware attribute object to get the middleware string

getName()

string

The route name

getPattern()

string

The route pattern to match

getPrefix()

string

hasDefaultValues()

bool

true if the route has default values defined, false if not

hasHosts()

bool

true if the Route has hosts defined, false if not

isFallback()

bool

true if the Route is a fallback route, false if not

isHoisted()

bool

true if the Route is hoisted out of its controller group, false if not

isOverride()

bool

true if the Route is an override route, false if not

Attribute Methods

This section list attributes that can be accessed from the Group and Route objects the methods to access the attribute data.

DefaultValue

Method

Return Type

Description

getParameter()

string

The parameter name

getValue()

string

The parameter value

Host

Method

Return Type

Description

getHost()

string

The host

Middleware

Method

Return Type

Description

getMiddleware()

string

The middleware string

Last modified: 28 November 2025