From Layered to Clean Architecture
Understand why dependencies should point inward.
Why Clean Architecture
You already know the classic three-layer PHP stack: Controller → Service → Repository → Database. It works, but the business logic ends up coupled to Eloquent, Doctrine, the HTTP request, and the framework lifecycle. Clean Architecture flips the dependency direction so your domain knows nothing about infrastructure. The reward: testable use cases, swappable adapters, and a codebase that survives framework upgrades.
The Dependency Rule
The single rule of Clean Architecture: source code dependencies point only inward. Inner circles (entities, use cases) must never reference outer circles (controllers, ORMs, frameworks). At runtime control flows outward via interfaces, but at compile/import time nothing inner imports anything outer.
- Entities: enterprise rules
- Use Cases: application rules
- Adapters: controllers, presenters, gateways
- Frameworks & Drivers: DB, HTTP, the web
All lessons in this course
- From Layered to Clean Architecture
- Ports and Adapters Explained
- Use Cases and Application Services
- Dependency Inversion in Practice