Clean and Hexagonal Architecture for Applications That Outlive the Framework.
Ports the domain owns. Adapters for Doctrine, Eloquent, HTTP and the queue. One composition root, and a test suite that never boots Laravel or Symfony. Both architectures, taught together, in PHP 8.3 idioms.
Kindle · Paperback · Hardcover

“A framework is something your application uses, not something your application is. The moment that flips, every upgrade becomes a migration and every business rule needs an HTTP request to run.”

Gabriel Anhaia
Senior Software Engineer · Berlin
Sound familiar?
None of that is Laravel's fault, or Symfony's. It is where you put the business logic.
What's inside
Cockburn's ports and adapters and Martin's four rings have been explained in Java for twenty years. This book teaches them together, in PHP, against real Laravel 11 and Symfony 7 codebases — not as Java translated into PHP syntax.
3 chapters
The framework trap. What coupling actually costs by year four. What Clean and Hexagonal each really promise, minus the buzzwords.
4 chapters
A domain of plain PHP objects. Ports written in the language of the business. Adapters at the edge. The dependency rule.
4 chapters
The four rings in PHP terms: entities, use cases, interface adapters — and a hard look at why the outer ring is replaceable.
3 chapters
Where Cockburn and Martin agree, where they don't, which to reach for — and the anti-patterns both of them forbid.
6 chapters
Layout and namespaces for PHP 8.3+. The domain, the ports, the use cases. Inbound and outbound adapters. The composition root.
5 chapters
Testing without a database. Errors across layers. Transactions, domain events, observability and authorization — all through ports.
5 chapters
When this is overkill. Refactoring a live Laravel service, then a Symfony one. The strangler pattern. The complete reference service.
After reading
Read it in your language
Each translation is its own edition on its own Amazon storefront. Formats vary by language — the English edition ships in all three.
Code you can run, not code you can read
Runnable companion code, Dockerized and organised chapter by chapter. Bring up the container, run the suite, then change the adapters and watch the domain tests stay green.
github.com/gabrielanhaia/php-clean-hexagonal-examples
About the author
Senior Software Engineer in Berlin. He started his career in PHP and shipped production services on Laravel, Symfony, Yii and CodeIgniter before carrying the same backend craft into Go, TypeScript and the JVM — long enough to watch the same architectural mistake resurface in four different syntaxes.
Also the author of Hexagonal Architecture in Go and creator of Hermes IDE, an open-source AI-native terminal.
Frameworks have a shelf life
30 chapters that move your business rules out of the request cycle and into code that will still make sense after the next major version.
Kindle · Paperback · Hardcover