Route
in package
Registers a controller action method as a Symfony route.
Routes defined with this attribute are compiled at composer dump-autoload into
vendor/composer/maho_attributes.php and loaded into Symfony's RouteCollection
at runtime, taking priority over XML-configured catch-all routes.
Run composer dump-autoload after adding, modifying, or removing this attribute.
This attribute is repeatable — apply multiple times for different paths or methods.
Attributes
- #[Attribute]
- \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE
Table of Contents
Properties
- $area : string|null
- $defaults : array<string|int, mixed>
- $methods : array<string|int, mixed>
- $name : string|null
- $path : string
- $requirements : array<string|int, mixed>
Methods
- __construct() : mixed
Properties
$area
public
string|null
$area
= null
$defaults
public
array<string|int, mixed>
$defaults
= []
$methods
public
array<string|int, mixed>
$methods
= []
$name
public
string|null
$name
= null
$path
public
string
$path
$requirements
public
array<string|int, mixed>
$requirements
= []
Methods
__construct()
public
__construct(string $path[, string|null $name = null ][, array<string|int, string> $methods = [] ][, array<string|int, mixed> $defaults = [] ][, array<string|int, mixed> $requirements = [] ][, string|null $area = null ]) : mixed
Parameters
- $path : string
-
URL path pattern (e.g. '/catalog/product/view/{id}')
- $name : string|null = null
-
Route name for URL generation, auto-generated from class::method if omitted
- $methods : array<string|int, string> = []
-
Allowed HTTP methods (e.g. ['GET', 'POST']). Empty = any method.
- $defaults : array<string|int, mixed> = []
-
Default parameter values
- $requirements : array<string|int, mixed> = []
-
Regex constraints for parameters (e.g. ['id' => '\d+'])
- $area : string|null = null
-
Area scope: 'frontend' or 'adminhtml'. Auto-detected from controller class if omitted.