giacomomasseron/php-clean-architecture
62.4
Adequate · 8 November 2026
1.2k
lines of production code
PHP
primary language
7
measurements over time
What this system is
Features
Added clean-architecture stubs and configuration templates
The package now includes a set of stub files in the \stubs/\ directory to help users scaffold a clean architecture project. These include base class templates for Controller, Entity, Repository, Service, and UseCase components, which implement specific interfaces from the \GiacomoMasseroni\\PHPCleanArchitecture\\Contracts\ namespace. Additionally, configuration stubs for Deptrac (defining layer dependencies) and Rector (configuring code-quality rules for the architecture) are provided to enforce structural integrity from the start.
stubs · high confidence
Introduces CLI commands for scaffolding and architecture enforcement
Adds a new set of command-line tools in src/Commands to help users scaffold clean-architecture components and enforce code standards. The InstallCommand copies and configures deptrac, rector, and project config files into the user's root directory. The CheckCommand runs the deptrac static analysis tool, while the RectorCommand applies PHP rector rules for automated refactoring. Additionally, a family of Make\* commands (MakeController, MakeEntity, MakeRepository, MakeService, MakeUseCase) generates new class files from stubs, automatically placing them in the correct directories and namespaces defined in the project configuration.
src/Commands · high confidence
Introduces CLI scaffolding and architecture validation for Clean Architecture
Adds a new CLI tool (\php-clean-architecture\) that provides commands to scaffold project structure (\make:entity\, \make:repository\, \make:use-case\, \make:controller\, \make:service\) and validate architectural integrity (\check\). The tool enforces Clean Architecture layering using \deptrac\ and \rector\, ensuring dependencies flow correctly from Controllers down to Entities. It also introduces marker interfaces for each layer (Entity, Repository, UseCase, Controller, Service) and a \BaseUseCase\ class to standardize use case implementation and event handling.
(repo-wide) · high confidence
Introduction of new contract interfaces and strict typing enforcement
The Contracts layer now includes new interfaces for Command, Controller, Entity, Repository, and Service to support clean architecture patterns, alongside a specific CommandInterface that defines an execute method accepting arguments and output. Additionally, existing interfaces (UseCaseExecutorInterface and UseCaseInterface) have been updated to enforce strict types via declare(strict\_types=1).
src/Contracts · high confidence
New PHPCleanArchitectureRectorableTrait for automatic interface implementation
A new PHP trait, PHPCleanArchitectureRectorableTrait, has been added to the src/Concerns directory. This trait provides reusable logic for Rector-based code refactoring, specifically enabling the automatic addition of interface implementations to classes within configured target namespaces. It includes methods to detect existing implementations, verify namespace membership, and modify class nodes to implement specified interfaces, streamlining adherence to clean architecture patterns during static analysis and code transformation.
src/Concerns · high confidence
New Rector rules to enforce clean architecture interfaces
This change introduces a new \LevelsEnum\ and five Rector rules that automatically add specific interface implementations (Controller, Entity, Repository, Service, and UseCase) to classes matching defined conditions, helping developers adhere to clean architecture patterns.
src/Enums, src/Rector · high confidence
Behavioural changes
Use case execution now supports static invocation and event dispatching
The \BaseUseCase\ class has been refactored to allow static invocation via \UseCase::run()\, replacing the previous instance-based execution model. This change introduces a singleton pattern within the use case lifecycle and integrates with the \Dispatcher\ to emit \UseCaseStartedEvent\ and \UseCaseCompletedEvent\ around the execution of the \handle\ method. Additionally, the \Logger\ class has been removed and replaced by a \CommandNotFoundException\ to handle invalid CLI commands, and the \PHPCleanArchitectureException\ base class now correctly accepts a nullable previous exception. Also in this area: 1 commit (0 fixes) modifying src/Exceptions.
src, src/Exceptions · medium confidence
Test coverage
4 commits adding/updating tests in tests
Test coverage in tests — 4 commits (3 fixs), 2 files: “fix: a use case running itself statically gets its own instance”; “fix: static run() on a use case with a non-public constructor”; “feat: constructor injection for use cases”; and 1 more. Also in this area: Added feature tests for CLI behavior and use-case dispatching.
tests · high confidence · unverified
Dependencies
Update dependencies and add deptrac to production requirements
The project now requires PHP 8.2 or higher and has added deptrac (version ^4.6) to the main production dependencies, alongside symfony/yaml and symfony/event-dispatcher (supporting versions 7.4 and 8.0). Several development tools have been updated or added: phpstan is now pinned to ^2.1, friendsofphp/php-cs-fixer to ^3.0, and composer/composer ^2.9 has been added to dev dependencies. The minimum stability has been raised from 'dev' to 'stable', and a binary entry point 'php-clean-architecture' has been defined.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 62 → 62 (+0.0)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 70 → 70 (+0.0)
- Architecture 69 → 69 (+0.0)
- Maturity 70 → 70 (+0.0)
- Readiness 57 → 57 (+0.0)
- Security 65 → 65 (+0.0)
New (1)
- Repeated repair: src/BaseUseCase.php (src/BaseUseCase.php)
Changes since last survey
- 10 commits — 7 feature/other, 3 fixes
By area
- (root) — 6 commits
- src/BaseUseCase.php — 3 commits
- tests/Feature — 1 commit
Notable commits
- fix: fix: a use case running itself statically gets its own instance
- fix: fix: run() on an instance runs that instance
- fix: fix: static run() on a use case with a non-public constructor
- change: Update CHANGELOG
- change: Update CHANGELOG
- change: docs: add CHANGELOG.md
- change: docs: dependency injection for use cases
- change: docs: state on a use case instance persists between runs
- change: docs: strict-rules, typed arguments and the new exception
- change: feat: constructor injection for use cases
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
giacomomasseron/php-clean-architecture was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 8 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit fa7d5f1b0781fa1f4c1e28c79e197a88d9089f31 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-45ab2cab63de.