The attribute-first PHP framework built for PHP 8.4.
MonkeysLegion is a modular, PSR-compliant framework that leverages PHP 8.4 property hooks, a compiled DI container, and 26 focused packages to deliver the speed of a micro-framework with the batteries of a full-stack one — without runtime magic.
Everything changed. Nothing feels heavy.
v2.0 is a full architectural pass across the entire ecosystem. Every package is pinned to v2.0+ for API consistency, the DI container compiles to zero-overhead resolution, and PHP 8.4 property hooks replace magic across the board.
PHP 8.4 Property Hooks
Native getters/setters as engine hooks — not reflection, not magic methods. Validation and formatting run at C speed.
Attribute-First Architecture
Routes, validation rules, service providers, and CLI commands are discovered via PHP 8 attributes. No giant route files, no YAML config graveyards.
Compiled DI Container
Production builds compile definitions to a PHP array written atomically to disk. Zero runtime reflection on the hot path.
MLC Configuration
A clean, typed config format with environment interpolation, cascading (.env → .env.local → .env.{APP_ENV}), and compiled production caching.
PSR-15 Security Pipeline
OWASP security headers, CORS, rate limiting, CSRF, trusted proxies, and request IDs — all as standard middleware, on by default.
Apex — Built-in AI Orchestration
Not a wrapper. A complete AI infrastructure layer with multi-provider routing, declarative pipelines, guardrails, agent crews, and cost management.
Three promises. Kept by design.
Benchmarked, not marketed.
All numbers produced on Apple Silicon with PHP 8.5.3, no opcache preloading, warm JIT, identical test harnesses.
Secure by default — not “secure once you install five packages.”
A direct, feature-by-feature comparison of what ships in the box versus what requires additional packages, configuration, or third-party bundles.
Apex Spotlight: The first PHP framework with an AI orchestration engine built in.
Main Tiles Slot
Multi-provider routing
Anthropic · OpenAI · Google (AI Studio + Vertex) · Ollama — same API, zero code change.
Declarative pipelines
pipe() · when() · loop() · parallel() · transform() — composable workflows with trace and timing.
Multi-agent crews
Sequential, Parallel, Hierarchical, Conversational — with lifecycle hooks and handoff tracking.
Guardrails engine
PII detection, prompt-injection defense, toxicity, regex, word count — with Block / Redact / Warn actions.
Structured output
Schema-based extraction to type-safe PHP classes with retries and JSON Schema generation.
Smart model router
CostOptimized · QualityFirst · LatencyFirst · RoundRobin strategies for tiered routing.
Cost management
Per-request tracking, pricing registry for 20+ models, budget enforcement, scoped reports.
MCP server + client
First-class Model Context Protocol support — serve tools and resources, or consume them.
Fallback chains
Ordered provider failover for high availability.
Streaming (SSE)
Token streaming, pipe-to-stream, SSE endpoints.
Six memory strategies
Conversation · Sliding · Summary · Vector · Persistent · Per-agent.
Tool calling
#[Tool] + #[ToolParam] attributes, multi-step autonomous loops.
Secondary Tiles Slot
Comparison Rows Slot
Nineteen capabilities. One composer install.
Items Slot
PSR Compliant
PSR-7, 11, 14, 15, 16, 17
Auth Suite
JWT, OAuth2, 2FA, RBAC, API keys, remember-me
Database Layer
QueryBuilder, migrations, entity scanner
Template Engine
Custom engine with caching and layouts
Attribute Routing
Auto-discovered, grouped, middleware-aware
Compiled DI
PSR-11 container with zero-overhead builds
Validation
Attribute-based with automatic DTO binding
I18n
File + database loaders, pluralization
SMTP and API delivery with DKIM
Telemetry
OpenTelemetry metrics, tracing, structured logs
Events
PSR-14 dispatcher with auto-discovery
Cache
Redis, file, in-memory (PSR-16)
Queue System
Background workers with retry and timeout
File Management
Unified storage, image processing, GC
OpenAPI v3
Auto-generated from route attributes
Apex AI
4 providers, pipelines, guardrails, crews
CLI Kernel
17+ make:* scaffolders
Security Middleware
OWASP, CORS, rate limit, CSRF, maintenance
Code Showcase: Show, don't tell.
Code Tabs Slot
Seventeen scaffolders. One CLI.
Every major framework object has a make:* command.
Scaffolding
Database
Operations
How a request flows.
Request Pipeline
(Static data rendered by frontend)
Boot Sequence
(Static data rendered by frontend)
From zero to serving traffic in 90 seconds.
Install, configure, and serve — three commands is all it takes.
Install
composer create-project monkeyscloud/monkeyslegion-skeleton my-app
cd my-app
Configure
cp .env.example .env
php ml key:generate
Serve
composer serve
# → http://127.0.0.1:8000
Tested. Compiled. Ready.
Every package ships with its own PHPUnit 11 suite. The framework meta-test suite covers 182 tests across 440 assertions:
Built forfive kinds of teams.
AI-native products
Apex gives you multi-provider routing, pipelines, guardrails, agent crews, and cost management as one Composer package.
API-first startups
Attribute routing + DTO validation + OpenAPI auto-gen + JWT = full REST API in a day.
High-throughput services
6× the HTTP req/s of Laravel at 18% the boot memory — measurable infrastructure savings at scale.
Enterprise / compliance
Argon2id, OWASP headers, token blacklisting, PII redaction guardrails, trusted-proxy middleware — all first-party.
Modern PHP shops
PHP 8.4 property hooks, strict types across all 26 packages, attribute-first everything — no more legacy __get() magic.
Where we're going.
Join the build.
MonkeysLegion is MIT-licensed and actively developed in the open.