acat/acat-slim

slim bridge

Maintainers

Package info

github.com/f-3-l-i-x/acat-slim

pkg:composer/acat/acat-slim

Transparency log

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 0

dev-main 2026-07-24 11:37 UTC

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\ActionsAction / AbstractAction base classes for Slim route handlers, plus ActionPayload / ActionError for a consistent JSON response envelope ({"statusCode": ..., "data": ...} or {"statusCode": ..., "error": ...}).
  • ACAT\Slim\Middleware\Authorize — PSR-15 middleware that validates a bearer JWT (from the Authorization header or a cookie) against an allowed issuer/client/role and either injects the decoded token via a TokenInjectorInterface or attaches it as a request attribute.
  • ACAT\Slim\Middleware\CORS — PSR-15 middleware that checks the Origin header against an allowlist, rejects disallowed origins with 403 in strict mode, and answers OPTIONS preflight 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.