Coesion/Core Framework Overview
This repository provides a lightweight PHP 8.5+ application core with routing, HTTP handling, persistence, configuration, and utilities.
It is designed for small-to-medium services and web apps that need a clear request lifecycle without a full-stack framework.
Usage overview:
- Autoloading:
Loaderregistersclasses/and resolves class names to files. - Namespaces: optional
Core\aliases are registered automatically (e.g.,Core\Route). - Configuration:
Optionsloads configuration from PHP, INI, JSON, arrays, or.envfiles. - Requests:
Requestreads headers, input, and body;Negotiationhandles Accept headers. - Routing:
Routedefines URL patterns and middleware, andRoute::dispatch()resolves requests. - Responses:
Responsebuilds and sends headers, body, and content types. - Persistence:
SQL,Persistence, andModelprovide a minimal ORM. - Events and filters:
Events,Event,Filters, andFilterenable hooks and overrides. - API:
API,Resource,Collection, andRESTprovide RESTful data exposure. - Utilities:
Text,Hash,Token,CSV,ZIP,Shell,Workand others support common tasks.
Typical use cases:
- HTTP APIs and web apps with simple routing and response handling.
- Internal tools or admin panels using
Viewfor template rendering. - Jobs and background processing via
JobandWork. - Data import/export pipelines using
CSVandZIP.
Performance:
- Autoload optimization:
composer dump-autoload -o - Build single-file artifact:
php tools/build-core.php - OPcache preload (web/FPM): set
opcache.enable=1,opcache.preload=/path/to/dist/core.php, andopcache.preload_user=www-data(or your PHP-FPM user). Optional for partial control:opcache.file_cache=/path/to/opcache.
Single-file deploy (optional):
- Build:
php tools/build-core.php - Include:
require DIR . '/dist/core.php'; - Note:
dist/core.phpis generated from framework classes and optimized for preload/distribution.
FrankenPHP:
- Classic mode: works like standard PHP-FPM; no special changes required.
- Worker mode: use
tools/frankenphp-worker.phpand ensureResponse::reset()is called per request. - Docker + Caddyfile:
- Use the official FrankenPHP image and mount your app.
- Add a Caddyfile route to your public entrypoint.
- Static binary guide: see
docs/guides/FrankenPHP.md.
Class reference:
- API
- REST
- Collection
- Resource
- Core
- Cache
- Auth
- Check
- CLI
- CSV
- CSRF
- Deferred
- Dictionary (abstract)
- Error (alias)
- Errors
- Event
- Events (trait)
- File
- Filter
- Filters (trait)
- Hash
- HTTP
- HTTP_Request
- HTTP_Response
- Gate
- Job
- Loader
- Map
- Message
- MessageReadOnly
- Migration
- Model (abstract)
- Module (trait)
- Negotiation
- Options
- Password
- Persistence (trait)
- Redirect
- Relation (trait)
- Request
- Response
- RateLimiter
- Route
- RouteGroup
- SecurityHeaders
- Service
- Session
- SessionReadOnly
- Shell
- SQL
- SQLConnection
- Structure
- TaskCoroutine
- Text
- Token
- URL
- View
- Work
- ZIP
Guides:
- Installation
- Packagist Artifact Publishing
- NPM Artifact Publishing
- Releasing
- Security Audit
- Examples
- FrankenPHP
- REST API With Auth
- Agentic Audit
- Agent Snapshot
- Agents Quickstart
- Agent Use Cases
- Why Core for Agents
- Interop
- Migrations
- Code Generation
- Agent KPIs
- Agent KPI Log
- Proof Weekly Template
- Distribution Playbook
- Router Benchmarks
- API
- REST
- Route Cache Extension
- Classes