PHP Best Practices Skillset
Implements TreeNation's DDD architecture for PHP backend components.
How to use this skill
- Identify which layers are involved (presentation, application, domain, infrastructure).
- Load only the relevant rule files from
rules/. - Apply rules in this order:
- correctness and architecture compliance
- type safety and strict typing
- testability
- code style (CS Fixer / PHPStan)
- Verify with PHP CS Fixer and PHPStan before finishing.
Repository-Specific Rules
- Follow project-local
CLAUDE.mdand repository conventions first. - New PHP files go inside
src/except controllers (app/Http/Controllers/). - Use
declare(strict_types=1)in every new file. - Controllers extend
ApiControllerand use__invokefor single-action controllers. - Services are injected via constructor; never instantiated with
newinside controllers. - Always register new repository bindings in
app/Providers/TreeNationProvider.php. - Do not add code comments unless the user asks.
Rule Categories
1) Controllers
rules/thin-controllers.mdrules/invokable-controllers.mdrules/request-validation-class.md
2) DTOs
rules/when-to-use-dtos.mdrules/immutable-dtos.md
3) Services
rules/service-business-logic.mdrules/service-response-pattern.md
4) Repositories
rules/repository-interface.mdrules/eloquent-repository-implementation.mdrules/criteria-pattern.md
5) Dependency Injection
rules/register-bindings.md
6) Testing
rules/unit-test-services.md