Skip to content

CQRS everywhere? No, only where it's useful

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.

Phexium offers two architectural modes that coexist within the same application:

  • Bus Mode: Commands and Queries flow through buses. Handlers manage transactions, publish events, and middleware intercepts for authorization or logging. This is the mode suited to business operations with side effects.
  • Direct Mode: The controller calls a UseCase directly, which returns a Response. No bus, no middleware, no automatic events. This is the mode suited to simple reads or prototyping.

In the demo application, the Homepage module uses Direct Mode. The other modules use Bus Mode. The choice is made at the module level, based on actual needs.

Result: Clean Architecture without CQRS boilerplate on the simple modules.