From MVC to Clean Architecture: what happens to your Model?
You have been doing MVC for ten years. Someone drops "Clean Architecture" in a meeting. You nod.
But concretely, what becomes of your Model?
You have been doing MVC for ten years. Someone drops "Clean Architecture" in a meeting. You nod.
But concretely, what becomes of your Model?
At the start of a project, you lay down grand principles: "the Domain never imports the Application layer", "Controllers do not access repositories directly." Three months later, an import slips through, nobody notices, and the boundaries fade away.
Testing code that uses new DateTime('now') or time() is painful. You end up mocking native functions, or accepting fragile tests that fail at midnight.
Direct dependency on a concrete implementation causes the same kind of problems for the logger, the cache, or the ID generator...
In many PHP projects, CQRS is applied systematically. Every operation goes through a Command or Query Bus, with handlers, middleware, and event dispatching. For a homepage that displays three statistics, that is pointless boilerplate.
CQRS is not the problem. Its systematic application is.
It is a common reflex: you start a project and rush into technical choices. PostgreSQL or MySQL? Docker or local database? Schemas, migrations, connections... Meanwhile, the real value of the project, the business logic, waits patiently for its turn.