
A production SaaS on Yii2: business logic spread across controllers, models and jobs, no static analysis, slow database-heavy tests.
What I did: introduced bounded contexts with strict layers (Domain, Application, Infrastructure, Presentation); added a command/query bus where every command runs in a transaction and each message has exactly one handler; put the dependency rules under Deptrac and the new code under PHPStan level 8 in CI; moved features over only when they were being changed anyway.
Result: releases never stopped, new features are written in the new structure and covered by fast unit tests, legacy shrinks with every change.
0 likes · 0 views · Nov 20, 2026
Step-by-step migration of a large Yii2 SaaS to DDD/CQRS layers under PHPStan level 8 and Deptrac, without stopping releases.