Agent skill
PHP Best Practices
PHP best practices, PSR standards, and code quality guidelines.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/best-practices-hoangnguyen0403-agent-skills-standar
Metadata
Additional technical details for this skill
- labels
-
php psr best-practices
- triggers
-
{ "files": [ "**/*.php" ], "keywords": [ "psr-12", "camelCase", "PascalCase", "dry", "solid" ] }
SKILL.md
PHP Best Practices
Priority: P1 (HIGH)
Structure
src/
├── {Domain}/ # e.g., Services, Repositories
└── Helpers/ # Pure functions/Traits
Implementation Guidelines
- PSR-12: Follow PSR-12 for coding style (indent, braces, space).
- Autoloading: Use PSR-4 via Composer.
- Namespacing: Map namespaces to directory structure.
- PascalCase: Use for all class names.
- camelCase: Use for methods and variables.
- SNAKE_CASE: Use for class constants.
- DRY Logic: Extract repetitive logic into traits/methods.
- SOLID: Use interfaces for decoupling and SRP adherence.
Anti-Patterns
- God Classes: No Monoliths: Avoid classes with multiple responsibilities.
- Magic Numbers: No Hardcoding: Use class constants for config values.
- Deep Nesting: No Nesting: Guard clauses over nested if/else.
- Direct Output: No Echo: Return data; let controller handle response.
References
- Clean Code Patterns
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?