chani/safi-core

Core Package for Safi Microframework

Maintainers

Package info

github.com/chani/safi-core

pkg:composer/chani/safi-core

Transparency log

Statistics

Installs: 28

Dependents: 9

Suggesters: 1

Stars: 0

Open Issues: 0

v0.1.18 2026-08-02 09:53 UTC

This package is auto-updated.

Last update: 2026-08-02 09:54:37 UTC


README

Core package for the Safi Microframework (PHP 8.5+). Built around pure constructor injection, explicit composition root wiring, an HTTP context pipeline, attribute routing, and driver contracts.

Architecture Principles

1. Pure Constructor Injection (Assembler)

  • No Service Locators: Controllers and services never pull from a global container. All dependencies are explicitly declared in constructors via PHP 8.5 property promotion.
  • Composition Root: The Assembler is used exclusively during application startup (init.inc.php or CLI entry points) to wire components together deterministically.

2. HTTP Pipeline & Context (Context)

  • Combines Request, Response, and LoggerInterface into a strict Context object flowing through the MiddlewarePipeline.
  • Eliminates messy parameter lists and keeps infrastructure concerns out of domain logic.

3. Attribute Routing (#[Route])

  • Routes are defined via PHP attributes directly on controller methods.
  • Unauthenticated requests are redirected or rejected by authentication middleware configured in the pipeline.

Package Layout

src/
├── Attributes/       # #[Route] definition
├── Cli/              # Command interface & kernel
│   └── Commands/     # Core maintenance tasks
├── Contracts/        # Interfaces (Router, View, Database, Search)
├── Event/            # Synchronous event dispatcher
├── Exception/        # Core exceptions
├── Http/             # Request, Response, Context, Pipeline
├── Services/         # Cache, JobQueue, Security
└── Util/             # Token-based class finder

License

Distributed under the MIT License. Author: Jean Bruenn