Real Decision

Repository Pattern in Yii2

Problem

ActiveRecord provides convenience, but business services become tightly coupled to persistence when queries are scattered throughout the codebase.

Decision

Repositories became the only place responsible for database access. Services interact through repository interfaces, allowing business rules to remain independent from storage implementation and simplifying testing.