Attribute
Attribute
PHP attribute-based route loader.
class Attribute extends \Hazaar\Application\Router\Loader\AdvancedExtends: Hazaar\Application\Router\Loader\Advanced
This loader resolves a controller route via the parent advanced loader, inspects the controller's public methods for Hazaar\Application\Route attributes, and registers each discovered endpoint on the global router.
Behavior summary:
- Controller selection is delegated to Hazaar\Application\Router\Loader\Advanced::evaluateRequest.
- Method-level
Routeattributes are instantiated as endpoint definitions. - Each endpoint is bound to the reflected controller method and prefixed with the resolved controller name.
- If the controller has no route attributes, a Hazaar\Application\Router\Exception\ControllerHasNoRoutes exception is thrown.
Methods
evaluateRequest
Evaluates the request and dynamically registers route attributes for the resolved controller.
public evaluateRequest(Request $request): ?RouteReturns: Hazaar\Application\Route
Parameters
| Parameter | Type | Description |
|---|---|---|
$request | Hazaar\Application\Request | incoming application request |
getRoutes
Statically enumerates every route declared via #[Route] attributes across every controller
public getRoutes(): arrayReturns: array
under the app's Controllers path, registering each on the router.
Unlike Hazaar\Application\Router\Loader\Attribute::evaluateRequest — which only ever loads the single controller resolved for the current request, deliberately avoiding a full directory scan on every real request — this eagerly scans and registers everything. That's an acceptable one-time cost for callers that need the full route table up front (for example the OpenAPI generator, or a live /openapi.json route hit once per long-lived worker), but means it shouldn't be called from the normal per-request dispatch path.
loadEndpoints
private loadEndpoints(string $controllerName, string $controllerClass): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$controllerName | string | |
$controllerClass | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:17 +0000