Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthias Noback:
Simple CQRS - reduce coupling, allow the model(s) to evolve
Jan 15, 2018 @ 12:55:31

Matthias Noback has posted about CQRS (Command Query Responsibility Segregation) on his site showing how to reduce coupling and let the "model(s) evolve" that tries to break down some of the perceived complexity around the design technique.

CQRS has some reputation issues. Mainly, people will feel that it's too complicated to apply in their current projects. It will often be considered over-engineering. I think CQRS is simply misunderstood, which is the reason many people will not choose it as a design technique.

[...] CQRS alone simply means that you're making a distinction between a model that is used for changing state, and a model that is used for querying state. In fact, there's often one model that accepts "write" operations (called "write model" or "command model") and multiple models that can be used to "read" information from (called "read models", or "query models").

He goes on to talk about the more common structure in applications, a single model that handles all of the usual CRUD operations rather than having it split up. He then moves on to the topic of coupling and reducing it through the use of read-only models. He shows examples of the code for these models as well as tips for dealing with inconsistent data.

tagged: cqrs coupling model evolve readonly tutorial example

Link: https://matthiasnoback.nl/2018/01/simple-cqrs-reduce-coupling-allow-the-model-to-evolve/