Simple CQRS - reduce coupling, allow the model(s) to evolve
CQRS - not a complicated thing
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. One of the common misconceptions is that CQRS always goes together with event sourcing, which is indeed more costly and risky to implement.
The release of "Microservices for everyone"
Today I’m happy to release my latest book, “Microservices for everyone”! 90% of it was done in July but you know what happens with almost-finished projects: they remain almost-finished for a long time. I did some useful things though, like preparing a print edition of the book.
Foreword
Finally, and I’m very proud of that, I received Vaughn Vernon’s foreword for this book. You may know Vaughn as the author of “Implementing Domain-Driven Design”. It made a lot of sense to ask him to write the foreword, since many of the ideas behind microservice architecture can be traced back to messaging and integration patterns, and Domain-Driven Design. Vaughn is an expert in all of these topics, and it was only to be expected of him to write an excellent foreword.
Preparing a Leanpub book for print-on-demand
During the last few days I’ve been finishing my latest book, Microservices for everyone. I’ve used the Leanpub self-publishing platform again. I wrote about the process before and still like it very much. Every now and then Leanpub adds a useful feature to their platform too, one of which is an export functionality for downloading a print-ready PDF.

Previously I had to cut up the normal book PDF manually, so this tool saved me a lot of work. Though it’s a relatively smart tool, the resulting PDF isn’t completely print-ready for all circumstances (to be honest, that would be a bit too much to ask from any tool of course!). For example, I wanted to use this PDF file to publish the book using Amazon’s print-on-demand self-publishing service CreateSpace, but I also wanted to order some copies at a local print shop (preferably using the same source files). In this post I’d like to share some of the details of making the print-ready PDF even more print-ready, for whomever may be interested in this.
Layers, ports & adapters - Part 3, Ports & Adapters
In the previous article we discussed a sensible layer system, consisting of three layers:
- Domain
- Application
- Infrastructure
Infrastructure
The infrastructure layer, containing everything that connects the application’s use cases to “the world outside” (like users, hardware, other applications), can become quite large. As I already remarked, a lot of our software consists of infrastructure code, since that’s the realm of things complicated and prone to break. Infrastructure code connects our precious clean code to:
Layers, ports & adapters - Part 2, Layers
The first key concept of what I think is a very simple, at the very least “clean” architecture, is the concept of a layer. A layer itself is actually nothing, if you think about it. It’s simply determined by how it’s used. Let’s stay a bit philosophical, before we dive into some concrete architectural advice.
Qualities of layers
A layer in software serves the following (more or less abstract) purposes:
Layers, ports & adapters - Part 1, Foreword
Looking back at my old blog posts, I think it’s good to write down a more balanced view on application architecture than the one that speaks from some of the older posts from 2013 and 2014. Before I do, I allow myself a quick self-centered trip down memory lane.
Why Symfony? Seven facts
The archive tells an interesting story about how my thoughts about software development changed over time. It all started with my first post in October 2011, How to make your service use tags. Back in those days, version 2 of the Symfony framework was still quite young. I had been working with symfony (version 1, small caps) for a couple of years and all of a sudden I was using Symfony2, and I absolutely loved this new shiny framework. I learned as much as I could about it (just as I had done with version 1), and eventually I became a Certified Symfony Developer, at the first round of exams held in Paris, during a Symfony Live conference. During those years I blogged and spoke a lot about Symfony, contributed to the documentation, and produced several open source bundles. I also wrote a book about it: A Year With Symfony.
Designing a JSON serializer
Workshop utilities
For the workshops that I organize, I often need some “utilities” that will do the job, but are as simple as possible. Examples of such utilities are:
- Something to dispatch events with.
- Something to serialize and deserialize objects with.
- Something to store and load objects with.
- Something to use with event sourcing (an event store, an event-sourced repository).
I put several of these tools in a code base called php-workshop-tools
. These utilities should be small, and very easy to understand and use. They will be different from the frameworks and libraries most workshop participants usually use, but they should offer more or less the same functionality. While designing these tools, I was constantly looking for the golden mean:
How to make Sculpin skip certain sources
Whenever I run the Sculpin generate
command to generate a new version of the static website that is this blog, I notice there are a lot of useless files that get copied from the project’s source/
directory to the project’s output/
directory. All the files in the output/
directory will eventually get copied into a Docker image based on nginx
(see also my blog series on Containerizing a static website with Docker). And since I’m on a hotel wifi now, I realized that now was the time to shave off any unnecessary weight from this Docker image.
Making a Docker image ready for use with Swarm Secrets
Here’s what I wanted to do:
- Run the official
redis
image as a service in a cluster set up with Docker Swarm. - Configure a password to be used by connecting clients. See also Redis’s
AUTH
command. The relevant command-line option when starting the redis server would be--requirepass
.
This is just a quick post, sharing what I’ve figured out while trying to accomplish all of this. I hope it’s useful in case you’re looking for a way to make a container image (an official one or your own) ready to be used with Docker Secrets.
The case for singleton objects, façades, and helper functions
Last year I took several Scala courses on Coursera. It was an interesting experience and it has brought me a lot of new ideas. One of these is the idea of a singleton object (as opposed to a class). It has the following characteristics:
- There is only one instance of it (hence it’s called a “singleton”, but isn’t an implementation of the Singleton design pattern).
- It doesn’t need to be explicitly instantiated (it doesn’t have the traditional static
getInstance()
method). In fact, an instance already exists when you first want to use it. - There doesn’t have to be built-in protection against multiple instantiations (as there is and can only be one instance, by definition).
Converting this notion to PHP is impossible, but if it was possible, you could do something like this: