ROUTING & HANDLERS FEATURE
Basic Route
One small payload class defines the endpoint. One small handler fills the response resource.
Feature Guide
A quick orientation block that answers the essential questions: what this feature does, how it works, why it matters, and the key concepts behind it.
What this does
A single #[AsPayload] attribute on a PHP class creates a fully routed HTTP endpoint — no XML, no YAML, no config files.
How it works
The framework scans the Composer classmap for classes with #[AsPayload], extracts path and method metadata, resolves env:: placeholders if present, and registers routes at boot. The route compiler then turns path patterns into optimized regex matchers cached in memory.
Why it matters
Keeping route definitions co-located with their request DTOs means a reader can understand what an endpoint accepts and where it lives by reading a single file. At the same time, env:: syntax lets operations move a route without reopening PHP code when deployment topology demands it.
Key concepts
- #[AsPayload]
- Attribute that marks a class as a request DTO and declares its HTTP route.
- env::VAR_NAME::/default/path
- Special attribute syntax that lets a payload read its route path, name, or other metadata from .env with a safe default fallback.
- responseWith
- Links the payload to the Resource DTO that shapes the response.
- ClassDiscovery
- Reads the Composer classmap to find all classes with a given attribute.
Route Discovery
Single attribute, live endpoint
This page exists because the payload declared the route directly in PHP and the handler only had to return the response resource.
GET /demo/routing/basic
Resolved route
Verified against Semitexa Ultimate 2026.09.19.1020
Basic Route
A single access attribute on a PHP class creates a fully routed HTTP endpoint — no XML, no YAML, no config files. Access is explicit at the type level: every payload picks one of #[AsPublicPayload], #[AsProtectedPayload], or #[AsServicePayload].
How it works
The framework scans the Composer classmap for classes carrying any of the three access attributes, extracts path and method metadata, resolves env:: placeholders if present, and registers routes at boot. The route compiler then turns path patterns into optimized regex matchers cached in memory.
Why this matters
Keeping route definitions co-located with their request DTOs means a reader can understand what an endpoint accepts and where it lives by reading a single file. The access attribute on the same line declares the security stance — anonymous, user-authenticated, or service-domain — so route review and security review collapse into one read. env:: syntax lets operations move a route without reopening PHP code when deployment topology demands it.
How it works
The framework scans the Composer classmap for classes with #[AsPayload], extracts path and method metadata, resolves env:: placeholders if present, and registers routes at boot. The route compiler then turns path patterns into optimized regex matchers cached in memory.
Why it matters
Keeping route definitions co-located with their request DTOs means a reader can understand what an endpoint accepts and where it lives by reading a single file. At the same time, env:: syntax lets operations move a route without reopening PHP code when deployment topology demands it.
Key concepts
- #[AsPayload]
- Attribute that marks a class as a request DTO and declares its HTTP route.
- env::VAR_NAME::/default/path
- Special attribute syntax that lets a payload read its route path, name, or other metadata from .env with a safe default fallback.
- responseWith
- Links the payload to the Resource DTO that shapes the response.
- ClassDiscovery
- Reads the Composer classmap to find all classes with a given attribute.