A modern PHP framework
built for clarity, not magic.
CQRS data access, JWT authentication, auto-wiring dependency injection, a composable middleware pipeline, attribute-based validation, structured error handling, and console tools — all with explicit, traceable code.
Everything you need, nothing you don't
A focused set of tools for building modern PHP applications with clear, predictable patterns.
CQRS Data Access
Separate Query and Command objects keep reads and writes distinct. No ORM magic, no hidden SQL — every data path is explicit and traceable through DbContext.
Multi-Provider Auth
OIDC, OAuth2, and local username/password authentication with JWT tokens. Validate tokens, extract claims, and check entitlements through a clean UserContext API.
DI Container
Auto-wiring container resolves constructor dependencies from type hints. Interface bindings, singletons, and service providers for modular registration.
Middleware Pipeline
PSR-15-style composable middleware for cross-cutting concerns. CORS, authentication, authorization, body parsing — stack them in any order.
MVC Views
Template engine with layouts, named sections, and ViewBag for passing data. Pure PHP templates — no new syntax to learn, with optional view caching.
Modern PHP
PHP 8.2+ features throughout: enums, readonly properties, constructor promotion, match expressions, named arguments, and union types.
Validation
Attribute-based validation rules on DTOs. Declare constraints directly on properties and validate incoming data with clear, structured error responses.
Error Handling
Centralized ExceptionHandler with automatic JSON or HTML response detection. Debug mode with stack traces in development, clean messages in production.
Console & Scaffolding
Project and entity scaffolding via the melodic CLI. Generate full CQRS stacks with a single command, plus route:list, cache:clear, and custom commands.
Up and running in minutes
Scaffold a project, generate entities, and start building.
# Create a new project (MVC + API by default)
composer require melodicdev/framework
vendor/bin/melodic make:project my-app
cd my-app && composer install
# Generate a full CQRS entity stack (8 files)
vendor/bin/melodic make:entity User
# Or scaffold API-only or MVC-only projects
vendor/bin/melodic make:project my-api --type=api
vendor/bin/melodic make:project my-site --type=mvc
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Melodic\Core\Application;
use Melodic\Http\Middleware\CorsMiddleware;
use Melodic\Http\Middleware\JsonBodyParserMiddleware;
use Melodic\Security\SecurityServiceProvider;
use Melodic\Security\ApiAuthenticationMiddleware;
$app = new Application(dirname(__DIR__));
$app->loadEnvironmentConfig();
// Register service providers
$app->register(new SecurityServiceProvider());
// Add middleware
$app->addMiddleware(new CorsMiddleware($app->config('cors') ?? []));
$app->addMiddleware(new JsonBodyParserMiddleware());
// Define routes
$app->routes(function ($router) {
$router->get('/', HomeController::class, 'index');
$router->group('/api', function ($router) {
$router->apiResource('/users', UserController::class);
}, middleware: [ApiAuthenticationMiddleware::class]);
});
$app->run();
Predictable request lifecycle
Every request follows the same path. No surprises, no hidden behavior.
A growing ecosystem
Documentation, tutorials, and tooling to support your projects.
Documentation
18 pages covering every framework feature — from configuration and routing to security, caching, and console commands.
Tutorials
Step-by-step guides from hello world to JWT authentication. Learn the framework by building real applications.
Service Providers
Modular packages for authentication, logging, events, and caching. Register what you need, skip what you don't.
Test Doubles
ArraySession, ArrayCache, and NullLogger for easy testing. Swap production services for in-memory implementations without configuration.
Ready to build something?
Start with the getting started guide, explore the documentation, or browse the source on GitHub.