Route
The one canonical route: the same immutable type you declare with `#[Route(...)]` on a controller method AND the value a matcher returns inside a {@see RouteResult}. It holds only static route facts — path, verbs, name, host, priority, defaults and per-route middleware; per-request path arguments live on the RouteResult. The `handler` is null only between declaration (an attribute cannot name its own method as a constant expression) and binding: the kernel calls {@see self::withHandler()} once reflection supplies the controller and method. Assert it with {@see self::isBound()}.
Route::__construct()
public function __construct(string $path, Milpa\Http\HttpMethod|array $methods = Milpa\Http\HttpMethod::GET, ?string $name = null, ?string $host = null, int $priority = 0, array $defaults = [], array $middleware = [], ?Milpa\Http\Routing\HandlerReference $handler = null):Parameters
| Name | Type | Description |
|---|---|---|
| $path | string | |
| $methods | (HttpMethod | non-empty-list<HttpMethod>) | one verb, or a list of verbs |
| $name | ?string | |
| $host | ?string | |
| $priority | int | |
| $defaults | array<string, string> | default values for optional path params |
| $middleware | list<class-string> | per-route PSR-15 middleware (kernel resolves via PSR-11) |
| $handler | ?Milpa\Http\Routing\HandlerReference |
Route::withHandler()
public function withHandler(Milpa\Http\Routing\HandlerReference $handler): selfBind the handler discovered by attribute reflection, returning a new instance.
Parameters
| Name | Type | Description |
|---|---|---|
| $handler | Milpa\Http\Routing\HandlerReference |
Route::withName()
public function withName(string $name): selfReturn a copy carrying the given route name.
Parameters
| Name | Type | Description |
|---|---|---|
| $name | string |
Route::allows()
public function allows(Milpa\Http\HttpMethod $method): boolWhether this route accepts the given HTTP method.
Parameters
| Name | Type | Description |
|---|---|---|
| $method | Milpa\Http\HttpMethod |
Route::isBound()
public function isBound(): boolWhether the handler has been bound (never null once the kernel has processed the route).