This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Always use composer scripts to run tests and static analysis:
composer phpunit— run full test suitecomposer phpunit -- --filter ClassName— run a single test classcomposer phpstan— run static analysiscomposer cs-fix— auto-fix code stylecomposer check— run all checks (cs-fix, cs-check, phpstan, phpunit)
Arcanum is a CQRS PHP framework (not MVC). It's a monorepo with packages under src/, each with a matching test directory under tests/. PHPUnit config is at contrib/phpunit.xml.
- Cabinet — DI container (PSR-11). Uses Codex for auto-wiring. Supports services, factories, singletons, prototypes, decorators, and middleware on services.
- Codex — Reflection-based class resolver. Resolves constructor dependencies recursively. Supports specifications (
when X needs Y give Z). - Flow — Data flow, four subpackages:
- Pipeline — linear stage chain (
object → object → object) - Continuum — middleware pattern (each stage calls
$next) - Conveyor — command bus (MiddlewareBus). Dispatches objects to handlers by naming convention (
PlaceOrder→PlaceOrderHandler). Combines Pipeline + Continuum for before/after middleware. - River — PSR-7 stream implementations
- Pipeline — linear stage chain (
- Echo — PSR-14 event dispatcher. Uses Flow Pipeline internally.
- Gather — Typed key-value registries.
Configuration(dot-notation),Environment(no serialize/clone),IgnoreCaseRegistry(HTTP headers). - Ignition — Bootstrap kernel.
HyperKernelruns bootstrappers: Environment → Configuration → Logger → Exceptions. - Hyper — PSR-7 HTTP messages and PSR-15 server handler.
- Glitch — Error/exception/shutdown handling with reporter system.
- Quill — Multi-channel PSR-3 logger over Monolog.
- Atlas — Convention-based CQRS router. Maps inputs (HTTP, CLI in future) to Query/Command namespaces. Core mapping is transport-agnostic; HTTP adapter extracts response format from file extensions.
- Shodo — Output rendering.
JsonRenderer,JsonExceptionRenderer, format registry (WIP). - Parchment — File utilities.
- Toolkit — String utilities.
- PHPUnit 13 with attributes:
#[CoversClass(...)],#[UsesClass(...)] - Strict coverage enabled — every test class must declare what it covers
- Tests mirror src structure:
src/Hyper/Headers.php→tests/Hyper/HeadersTest.php - Arrange-Act-Assert pattern throughout
- Fixtures live in
tests/Fixture/or in subpackage test directories
Arcanum embraces the full HTTP status code spectrum. When implementing any HTTP-facing feature, always use the most precise status code — never collapse to 200/404/500. Examples:
- Command returns void → 204 No Content, returns a DTO → 201 Created, returns null → 202 Accepted
- Valid path, wrong HTTP method → 405 Method Not Allowed (not 404)
- Unsupported response format → 406 Not Acceptable (not 400)
- Use
HttpExceptionwith the specificStatusCodeenum value, never raw integers
A WIP starter app lives at ../arcanum/ — it demonstrates how apps consume the framework via Cabinet container, HyperKernel, and config files.