php-best-practices
2
总安装量
2
周安装量
#63304
全站排名
安装命令
npx skills add https://github.com/tree-nation/php-best-practices --skill php-best-practices
Agent 安装分布
amp
2
gemini-cli
2
github-copilot
2
codex
2
kimi-cli
2
cursor
2
Skill 文档
PHP Best Practices
Use this skill as a rulebook for building and migrating PHP backend components following TreeNation’s DDD architecture.
Workflow
- Open
AGENTS.md. - Identify which components need to be created or changed (controller, service, DTO, repository, response, test).
- Load only the relevant rule files from
rules/. - Implement the smallest correct change that satisfies the requirement.
- Run PHP CS Fixer and PHPStan before finishing.
Repository Guardrails
- New PHP files go inside
src/except controllers (which stay inapp/Http/Controllers/). - Controllers must not contain business logic; delegate to a service.
- Services must be unit-tested; mock all dependencies.
- Always register new repository interfaces in
app/Providers/TreeNationProvider.php. - Use strict typing (
declare(strict_types=1)) in all new files. - Do not add comments unless the user explicitly asks.
- Follow the Criteria pattern for all repository queries.
- Commits follow pattern:
TNIT-####: description.
Output Expectations
- Explain which rules were applied and why.
- Generate all required files for the feature (controller, request, DTO if needed, service, response, repository interface, repository implementation, test).
- Keep changes incremental; avoid broad rewrites unless asked.