Router Register
RouterRegister allows routes to be defined in application source files using PHP Attributes amd Enumerations.
There are a number of benefits of defining and registering routes using RouterRegister:
Self-documenting code: it's clear that a method corresponds to a given route and what parameters, hosts, and middleware apply to the route.
Single point of truth: each route, its URI and name is defined in an enumeration, making maintenance simpler and providing IDE code completion.
Simplifies development and eliminates typos: IDE code completion for routes works when generating URLs as well.
RouterRegister parses generates an internal representation of the defined groups and routes from the Attributes and Enumerations. A framework specific Writer object then creates the router configuration files.
Installation
RouterRegister is installed as a dependency of a framework specific RouterRegister Writer package.
Usage
Using RouterRegister involves:
Creating Middleware Attributes (if required)
Defining groups (if required)
Running RouterRegister to generate router configuration files. This can be from a console command or on an HTTP request; if using the latter, the configuration files should be cached in a production environment.