acat / acat-slim
slim bridge
dev-main
2026-07-24 11:37 UTC
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.2
- phpunit/phpunit: ^12.2.7
This package is auto-updated.
Last update: 2026-07-24 11:37:44 UTC
README
A small bridge library on top of the Slim Framework, providing a common set of building blocks (actions, JWT-based authorization, CORS handling and error/shutdown handlers) shared across ACAT PHP services.
Requirements
Installation
composer require acat/acat-slim
What's included
ACAT\Slim\Actions—Action/AbstractActionbase classes for Slim route handlers, plusActionPayload/ActionErrorfor a consistent JSON response envelope ({"statusCode": ..., "data": ...}or{"statusCode": ..., "error": ...}).ACAT\Slim\Middleware\Authorize— PSR-15 middleware that validates a bearer JWT (from theAuthorizationheader or a cookie) against an allowed issuer/client/role and either injects the decoded token via aTokenInjectorInterfaceor attaches it as a request attribute.ACAT\Slim\Middleware\CORS— PSR-15 middleware that checks theOriginheader against an allowlist, rejects disallowed origins with403in strict mode, and answersOPTIONSpreflight requests.ACAT\Slim\Handlers\HttpErrorHandler/ShutdownHandler— Slim error/shutdown handlers that log unexpected errors and turn them into a JSON error response instead of leaking a raw PHP error to the client.ACAT\Slim\ResponseEmitter\ResponseEmitter— thin wrapper around Slim's response emitter that adds cache-control headers and clears stray output buffers before emitting the response.ACAT\Slim\Exception\AuthorizeException/RecordNotFoundException— exceptions used by the middleware/actions above to signal authorization failures and missing records.
CORS headers are only ever set by the CORS middleware, which checks the configured allowlist —
ResponseEmitter intentionally does not add any Access-Control-* headers itself.
Testing
composer install bin/phpunit
License
MIT, see LICENSE.