Modern PHP frameworks like Laravel are powerful, but sometimes you need something lighter. In this article we walk through building a minimal MVC framework that handles routing, dependency injection, and templating — all without a single Composer package.
Understanding how a framework works under the hood makes you a better developer. When you know how routing resolves a URL to a controller action, debugging becomes faster. When you understand how the view layer injects variables, you stop writing spaghetti code.
app/
Components/
Router.php
Model.php
Models/
endpoints/
public/
private/
index.phpThe router parses the URL and maps segments to controllers and actions. Our implementation extracts up to four segments: /scope/page/method/id.
Each controller declares which HTTP methods map to which PHP methods via allowedActions(). This simple whitelist keeps your API surface explicit and secure.
The best architecture is the one your whole team understands on day one.
A custom MVC framework built with care is often faster than a generic one. More importantly, you own every line — there are no surprise breaking changes between major versions.