- A controller that extends
AbstractApivalkController. - A request class that extends
AbstractApivalkRequest. - One or more response classes that extend
AbstractApivalkResponse.
RouteAuthorization entirely — the SecurityMiddleware treats the route as open.
Directory layout
src/Http/Controller, no registration step is needed — the controller is picked up by ClassLocator.
1. The request
Nothing to validate; just satisfy the interface:2. The response
3. The controller
What you get out of the box
- No
RouteAuthorization→ theSecurityMiddlewarepasses the request straight to the controller. Guest and authenticated clients are both accepted. - OpenAPI coverage →
GET /healthshows up in the generated spec with a200response whose schema matchesGetHealthResponse::getDocumentation(). - Locale + rate-limit headers →
Content-Languageis added by the middleware stack, and if you ever add a rate limit to this route, theX-RateLimit-*headers appear automatically.
Variations
- Add a
versionoruptimefield — extend the response with moreStringProperty/IntegerPropertyentries and include them intoArray(). - Return 503 when a dependency is down — declare a second response class (e.g.
ServiceUnavailableResponse) ingetResponseClasses(), and return whichever matches the actual check result. - Keep it public but log anonymous calls — read
$request->getAuthIdentity()->isAuthenticated()inside__invoke(); since noRouteAuthorizationwas set, the identity is always populated (guest or real) but never rejected.