TL;DR: MonkeysLegion is a lightweight, modular PHP framework that bundles everything you needβblazing-fast router, DI container, CLI tools, and zero-config Dockerβso you can focus on features instead of plumbing. It's MIT-licensed, open-source, and we're looking for collaborators!
Why Another PHP Framework?
Let's be honest: setting up a new PHP project can feel like assembling IKEA furniture without instructions. You need routing, dependency injection, database migrations, authentication, validation, caching... and by the time you've wired it all together, you've lost the motivation to build the actual thing.
MonkeysLegion changes that.
We built it because we were tired of the boilerplate. We wanted something that's:
- β‘ Fast to start β One composer command, and you're coding
- π§© Modular β Use only what you need
- π Production-ready β Built-in auth, validation, caching, and observability
- π Well-documented β Because code without docs is just legacy waiting to happen
Get Started in 60 Seconds
composer create-project monkeyscloud/monkeyslegion-skeleton my-app
cd my-app
cp .env.example .env
php ml key:generate
composer serve
Open http://127.0.0.1:8000 β you're live. π
What's in the Box?
MonkeysLegion isn't just another micro-framework. It's a complete ecosystem:
| Category | What You Get |
|---|---|
| HTTP Stack | PSR-7/15 compliant, middleware pipeline |
| Routing | Attribute-based, auto-discovery, caching |
| Database | Query Builder, Micro-ORM, Migrations |
| Auth | JWT, RBAC, 2FA, OAuth, API Keys |
| Validation | DTO binding with attribute constraints |
| Caching | File, Redis, Memcached drivers |
| CLI | Migrations, scaffolding, Tinker REPL |
| Telemetry | Prometheus metrics, distributed tracing |
Code That Speaks for Itself
Attribute-Based Routing
No more giant route files. Define routes right where they belong:
use MonkeysLegion\Router\Attributes\Route;
use MonkeysLegion\Router\Attributes\RoutePrefix;
use MonkeysLegion\Router\Attributes\Middleware;
#[RoutePrefix('/api/users')]
#[Middleware(['cors', 'throttle'])]
class UserController
{
#[Route('GET', '/', name: 'users.index')]
public function index(): Response
{
return $this->json(User::all());
}
#[Route('GET', '/{id:\d+}', name: 'users.show')]
public function show(string $id): Response
{
return $this->json(User::find($id));
}
#[Route('POST', '/', name: 'users.create')]
#[Middleware('auth')]
public function create(CreateUserRequest $request): Response
{
// Validated DTO is automatically injected
$user = User::create($request->validated());
return $this->json($user, 201);
}
}
Validation with DTOs
Type-safe request validation using PHP attributes:
use MonkeysLegion\Validation\Attributes as Assert;
final readonly class CreateUserRequest
{
public function __construct(
#[Assert\NotBlank]
#[Assert\Email]
public string $email,
#[Assert\NotBlank]
#[Assert\Length(min: 8, max: 64)]
public string $password,
#[Assert\Url]
public ?string $website = null,
) {}
}
Invalid requests automatically return structured errors:
{
"errors": [
{ "field": "email", "message": "Value must be a valid e-mail." },
{ "field": "password", "message": "Minimum length is 8 characters." }
]
}
Fluent Query Builder
Write readable database queries without raw SQL:
$users = $qb->from('users')
->leftJoin('profiles', 'p', 'p.user_id', '=', 'users.id')
->select(['users.*', 'p.avatar'])
->where('status', '=', 'active')
->whereIn('role', ['admin', 'editor'])
->orderBy('created_at', 'DESC')
->paginate(page: 1, perPage: 20);
Built-in Authentication
JWT auth with 2FA support, ready to use:
$result = $auth->login($email, $password, $request->ip());
if ($result->requires2FA) {
return response()->json([
'requires_2fa' => true,
'challenge' => $result->challengeToken,
]);
}
return response()->json([
'access_token' => $result->tokens->accessToken,
'refresh_token' => $result->tokens->refreshToken,
]);
Powerful CLI Tools
Scaffold your app without leaving the terminal:
php ml make:entity User # Generate Entity
php ml make:controller User # Generate Controller
php ml make:migration # Generate migration from entity diff
php ml migrate # Run migrations
php ml tinker # Interactive REPL
php ml openapi:export # Export OpenAPI spec
The Package Ecosystem
MonkeysLegion is built as independent packages. Use the full stack or pick what you need:
-
monkeyslegion-coreβ Kernel, events, helpers -
monkeyslegion-routerβ Full-featured routing -
monkeyslegion-authβ JWT, RBAC, 2FA, OAuth -
monkeyslegion-queryβ Query Builder & ORM -
monkeyslegion-cacheβ PSR-16 multi-driver cache -
monkeyslegion-filesβ File storage, chunked uploads, S3 -
monkeyslegion-mailβ SMTP, templates, DKIM, queues -
monkeyslegion-i18nβ Internationalization -
monkeyslegion-telemetryβ Metrics & tracing -
monkeyslegion-validationβ DTO validation -
monkeyslegion-templateβ MLView templating engine
Requirements
- PHP 8.4+
- MySQL 8.4 (recommended)
- Composer 2.x
We Need You! π€
MonkeysLegion is open-source and MIT-licensed. We're actively looking for collaborators who want to:
- π Report bugs and suggest features
- π Improve documentation
- π§ͺ Write tests
- π‘ Build new packages
- π Help with translations
No contribution is too small. Whether it's fixing a typo or implementing a new feature, we'd love to have you on board.
Join Our Community
We've set up a Slack workspace where you can:
- Ask questions and get help
- Discuss features and architecture
- Share what you're building
- Connect with other developers
π Join MonkeysLegion on Slack
Resources
- π Website: monkeyslegion.com
- π Documentation: monkeyslegion.com/docs
- π» GitHub: MonkeysCloud/MonkeysLegion-Skeleton
- π¦ Packagist: monkeyscloud/monkeyslegion-skeleton
Get Started Now
composer create-project monkeyscloud/monkeyslegion-skeleton my-app
Give it a β on GitHub if you like what you see!
Built with π by developers who believe PHP deserves better tooling.
What do you think? Have you tried MonkeysLegion? What features would you like to see? Drop a comment below or join us on Slack! π
Top comments (0)