I am currently looking into developing a new system utilizing hexagonal architecture and the commandpattern facilitated by a commandbus like tactician (it's a PHP system).
Now I really like the idea of the commandpattern but what I don't get yet is how to get back the actual result of what the command has done.
Lets say I issue a RegisterPatient command with the following fields:
- Name
- Address
- Birthdate
etc
The command has been filled with data from say a HTTP interface, given to the commandhandler and executed. If everything goes alright it will create a Patient object and persist it to the database. But the commandpattern does not let me return the constructed Patient object, in part because there is the possibility of adding middleware before and after, so it should return the command itself.
I get that there is a value in separating read from write applications but in practice, how do I get the data from the datastore after the command has been executed or read queries in general? Would it be unwise to inject the RepositoryInterface for a certain model directly into my controller if I wanted to generate an index view for instance?
What are practical ways to handle errors with commands?
Help much appreciated.