PHPackages                             monkeyscloud/monkeyslegion - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. monkeyscloud/monkeyslegion

ActiveLibrary[Framework](/categories/framework)

monkeyscloud/monkeyslegion
==========================

High-performance PHP 8.4 framework — attribute-first architecture, property hooks, compiled DI, MLC configuration.

2.0.14(2mo ago)22.7k↓25.3%[1 PRs](https://github.com/MonkeysCloud/MonkeysLegion/pulls)2MITPHPPHP ^8.4

Since Jul 23Pushed 2w ago2 watchersCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion)[ RSS](/packages/monkeyscloud-monkeyslegion/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (3)Dependencies (144)Versions (50)Used By (2)

MonkeysLegion Framework
=======================

[](#monkeyslegion-framework)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)[![PHP Version](https://camo.githubusercontent.com/8aa0bbcfc5fb3b53b6d5c17195e065d3d95a9286a24c145af184ce5ecc64aea7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d383839324246)](https://camo.githubusercontent.com/8aa0bbcfc5fb3b53b6d5c17195e065d3d95a9286a24c145af184ce5ecc64aea7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d383839324246)[![Version](https://camo.githubusercontent.com/db7cb9caa84ae6759da7999eb5fcad3561c8aa784e86d6b6500bda20356c5749/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302d627269676874677265656e)](https://camo.githubusercontent.com/db7cb9caa84ae6759da7999eb5fcad3561c8aa784e86d6b6500bda20356c5749/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302d627269676874677265656e)[![Tests](https://camo.githubusercontent.com/a5a38161e2dc73d78400de32611df625a6d0ccecf05e9d4ac9658948c882da15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3138322532307061737365642d73756363657373)](https://camo.githubusercontent.com/a5a38161e2dc73d78400de32611df625a6d0ccecf05e9d4ac9658948c882da15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3138322532307061737365642d73756363657373)[![PSR](https://camo.githubusercontent.com/d8552ab22aa425df7d72b6f4c1644b55bf08cc956fb1ad5ae59b9e0bd829c5fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d37253230253743253230313125323025374325323031342532302537432532303135253230253743253230313625323025374325323031372d626c7565)](https://camo.githubusercontent.com/d8552ab22aa425df7d72b6f4c1644b55bf08cc956fb1ad5ae59b9e0bd829c5fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d37253230253743253230313125323025374325323031342532302537432532303135253230253743253230313625323025374325323031372d626c7565)

**MonkeysLegion** is a high-performance, attribute-first PHP 8.4+ framework built for modern web applications and APIs. It leverages PHP 8.4 property hooks, strict types, and compiled DI to deliver a developer experience that rivals Laravel and Symfony — with zero runtime compromise.

---

🚀 What's New in v2.0
--------------------

[](#-whats-new-in-v20)

- **PHP 8.4 Property Hooks** — Native getters/setters via property hooks across all packages
- **Attribute-First Architecture** — Routes, validation, providers, and commands discovered via attributes
- **MLC Configuration** — `.mlc` file format with env interpolation, cascading, and production compilation
- **Compiled DI Container** — Zero-overhead production builds with atomic cache writes
- **26 Integrated Packages** — Every component pinned to v2.0+ for API consistency
- **PSR-15 Middleware Pipeline** — Native security headers, CORS, rate limiting, CSRF, and request ID
- **Apex AI/ML** — Built-in AI provider abstraction with OpenAI, cost tracking, and embeddings
- **182-Test Suite** — Comprehensive PHPUnit 11 test coverage across all framework layers

---

✨ Features
----------

[](#-features)

CategoryDetails**🎯 PSR Compliant**PSR-7, PSR-11, PSR-14, PSR-15, PSR-16, PSR-17**🔧 Modular**26 independent, composable packages**🔐 Auth**JWT, OAuth2, 2FA, API Keys, RBAC, Policies, remember-me**🗄️ Database**Connection manager, QueryBuilder, migrations, entity scanner**🎨 Templates**Custom engine with caching, layouts, and directives**🌐 Routing**Attribute-based, auto-discovered, grouped, middleware-aware**⚡ DI**PSR-11 container with compiled cache for production**📝 Validation**Attribute-based validation with DTO binding**🌍 I18n**Multi-language with database and file loaders**📧 Mail**SMTP and API-based email delivery**📊 Telemetry**OpenTelemetry-compatible metrics, tracing, and structured logging**🎪 Events**PSR-14 event dispatcher with listener auto-discovery**💾 Cache**Redis, file, in-memory backends (PSR-16)**📨 Queue**Background job processing with workers and retry**📁 Files**Unified storage, image processing, garbage collection**📚 OpenAPI**Auto-generated API docs from route attributes**🤖 AI/ML**Apex: OpenAI provider, cost tracking, embeddings**🔄 CLI**Attribute-discovered commands, schedule, dev-server**🛡️ Security**OWASP headers, CORS, rate limiting, CSRF, maintenance mode---

📦 Included Packages
-------------------

[](#-included-packages)

PackageVersionDescription`monkeyslegion-core`^2.0Core utilities, helpers, and base contracts`monkeyslegion-di`^2.0PSR-11 dependency injection container`monkeyslegion-http`^2.0PSR-7/PSR-15/PSR-17 HTTP layer and security middleware`monkeyslegion-router`^2.1Attribute-based routing with auto-discovery`monkeyslegion-database`^2.0Connection manager, PDO abstraction, transactions`monkeyslegion-query`^2.0Fluent QueryBuilder with grammar compilation`monkeyslegion-entity`^2.0Entity scanner and metadata extraction`monkeyslegion-migration`^2.0Database migration generator and runner`monkeyslegion-auth`^2.1JWT, session guards, password hashing, RBAC`monkeyslegion-validation`^2.0Attribute-based validation and DTO binding`monkeyslegion-cache`^2.0PSR-16 cache: Redis, file, in-memory stores`monkeyslegion-session`^2.0Session manager with CSRF middleware`monkeyslegion-template`^2.0Template engine with caching and layouts`monkeyslegion-events`^2.0PSR-14 event dispatcher`monkeyslegion-logger`^2.0PSR-3 logger with rotating file handlers`monkeyslegion-queue`^1.2Queue factory, workers, and job dispatching`monkeyslegion-schedule`^1.1Task scheduling with cron expressions`monkeyslegion-mail`^1.1SMTP and API-based email`monkeyslegion-i18n`^2.1Internationalization and locale management`monkeyslegion-telemetry`^2.0Metrics, distributed tracing, request middleware`monkeyslegion-files`^2.0File storage, image processing, garbage collection`monkeyslegion-mlc`^3.2MLC config parser with env interpolation`monkeyslegion-cli`^2.0CLI kernel with attribute-discovered commands`monkeyslegion-apex`^1.0AI/ML abstraction: OpenAI, cost tracking`monkeyslegion-openapi`^1.0Auto-generated OpenAPI v3 documentation`monkeyslegion-dev-server`^1.0Built-in development server---

🔨 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- **PHP 8.4+** (uses property hooks and modern features)
- **Composer 2.x**
- **MySQL/MariaDB/PostgreSQL/SQLite** (any PDO-supported database)
- **Redis** (optional — for caching, queues, sessions, and rate limiting)

### Quick Start

[](#quick-start)

```
# Install via Composer
composer create-project monkeyscloud/monkeyslegion my-app

# Or add to an existing project
composer require monkeyscloud/monkeyslegion
```

### Project Structure

[](#project-structure)

```
my-app/
├── app/
│   ├── Controller/         # HTTP controllers with route attributes
│   ├── Entity/             # Database entities
│   ├── Provider/           # Custom service providers
│   └── Middleware/         # Custom middleware
├── bootstrap/
│   ├── app.php             # Application factory
│   └── env.php             # Environment loader
├── config/                 # MLC configuration files
│   ├── app.mlc
│   ├── auth.mlc
│   ├── database.mlc
│   └── ...
├── public/
│   └── index.php           # HTTP entry point
├── resources/
│   └── views/              # Templates
├── tests/                  # PHPUnit test suite
├── var/
│   ├── cache/              # Compiled container, templates
│   └── logs/               # Application logs
├── .env                    # Environment variables
├── composer.json
└── phpunit.xml

```

---

🏗️ Architecture
---------------

[](#️-architecture)

### Boot Sequence

[](#boot-sequence)

```
public/index.php
  └── bootstrap/app.php
        └── Application::create(basePath)
              ├── ENV cascade: .env → .env.local → .env.{APP_ENV} → .env.{APP_ENV}.local
              ├── MLC config: config/*.mlc → Loader → Config (compiled in production)
              ├── Service Providers: AppConfig → 19 providers → DI Container
              ├── SAPI detection: HTTP → Kernel | CLI → CliKernel
              └── run()

```

### Request Lifecycle (HTTP)

[](#request-lifecycle-http)

```
┌─────────────────────────────────────────────────┐
│  ServerRequest::fromGlobals()                   │
├─────────────────────────────────────────────────┤
│  CoreRequestHandler (PSR-15 Pipeline)           │
│  ├── SecurityHeadersMiddleware (OWASP)          │
│  ├── TrustedProxyMiddleware                     │
│  ├── RequestIdMiddleware                        │
│  ├── CorsMiddleware                             │
│  ├── RateLimitMiddleware                        │
│  ├── MaintenanceModeMiddleware                  │
│  ├── SessionMiddleware                          │
│  ├── VerifyCsrfToken                            │
│  ├── AuthenticationMiddleware                   │
│  └── Router → Controller → Response             │
├─────────────────────────────────────────────────┤
│  SapiEmitter → Client                          │
└─────────────────────────────────────────────────┘

```

---

📚 Usage Guide
-------------

[](#-usage-guide)

### Entry Point (v2.0)

[](#entry-point-v20)

**public/index.php**

```
