Building a PHP framework from scratch is often seen as an academic exercise, but in reality it is one of the most effective ways to deeply understand how modern frameworks work.

Why build your own framework?

Frameworks like Symfony or Laravel hide a lot of complexity behind elegant APIs. That is great for productivity, but it can also obscure important architectural decisions.

By creating a minimal framework, you are forced to confront fundamental questions:

  • How does a request enter the system?
  • Who is responsible for routing?
  • Where does dependency injection actually happen?
  • How do middleware and controllers interact?

The Kernel as the central orchestrator

At the heart of any serious framework lies a Kernel. Its job is not to do the work itself, but to coordinate it. In your mini-framework, the Kernel is responsible for bootstrapping the container, loading routes, initializing middleware, and dispatching the request.

This design closely mirrors Symfony’s HttpKernel, but without unnecessary abstraction layers.

Why this matters

Keeping orchestration separate from business logic makes your system testable, maintainable, and extensible. You can swap implementations without rewriting your application.

Routing as pure configuration

Your router does not execute code. It only describes intent. This is a crucial design choice that prevents tight coupling between HTTP concerns and application logic.

Conclusion

Writing your own framework is not about competing with Symfony. It is about understanding the trade-offs that large frameworks make, so you can make better decisions in your own projects.