Routing
Routing in Semitexa PHP: basic and parameterized routes, payloads as a typed shield, content negotiation, the HTTP lifecycle and route debugging.
-
Basic Route
Define a route with one access attribute on the payload. No XML, no YAML, no config files.
-
Adding Pages and Routes
Creating a module and its first route end to end: JSON and HTML responses, where each class goes, how discovery finds it, a custom 404, and the usual mistakes.
-
Parameterized Route
Path parameters with regex constraints, how the hydrator injects them, and why a default does not make a segment optional.
-
Env Route Override
Keep the payload as the route source of truth while allowing operations to remap the public URL through .env.
-
Payload As A Shield
Hydration happens before the handler, and each setter owns the normalization and guard logic for its own field.
-
Payload Parts
One module owns the route, another module can extend the same payload contract without forking or reopening the base class.
-
Content Negotiation
One endpoint, many formats: the same Semitexa route answers HTML, JSON and more, picked automatically from the request's Accept header.
-
Public Payload
Anonymous endpoints opt in explicitly with the public access attribute. Every other payload requires authentication.
-
Debugging Routes
Three commands that answer why a route is not matching, what it resolves to, and which template finally renders it.
-
Rate Limiting
Limit a route with #[RateLimit] or any action with RateLimiter — per address or per user, held across workers, answered with 429 and Retry-After.