
php-best-practices
by jcastillotx
My skeleton for app builds
SKILL.md
name: php-best-practices description: PHP coding standards and best practices. This skill should be used when writing, reviewing, or refactoring PHP code. Triggers on tasks involving PHP applications, WordPress plugins, Laravel projects, or any PHP-based backend. trigger_patterns:
- php
- composer
- psr-4
- namespace
- wordpress plugin
- laravel auto_load_with:
- wordpress-best-practices
- laravel-best-practices
- mysql-best-practices
PHP Best Practices
Comprehensive coding standards for PHP development, optimized for AI agents and LLMs. Contains 24 rules across 8 categories, prioritized by impact.
When to Apply
Reference these guidelines when:
- Writing PHP application code
- Developing WordPress plugins or themes
- Building Laravel applications
- Implementing security measures
- Optimizing PHP performance
- Following PSR standards
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Security | CRITICAL | security- |
| 2 | Error Handling | HIGH | error- |
| 3 | Performance | HIGH | perf- |
| 4 | Type Safety | MEDIUM-HIGH | types- |
| 5 | OOP Patterns | MEDIUM | oop- |
| 6 | PSR Standards | MEDIUM | psr- |
| 7 | Testing | MEDIUM | test- |
| 8 | Modern PHP | LOW-MEDIUM | modern- |
Quick Reference
1. Security (CRITICAL)
security-input-validation- Validate with filter_var()security-output-escaping- Escape based on contextsecurity-password-hashing- Use password_hash()security-csrf-tokens- Implement CSRF protectionsecurity-no-eval- Never use eval()
2. Error Handling (HIGH)
error-exception-handling- Use try-catch properlyerror-custom-exceptions- Create domain exceptionserror-error-reporting- Configure error levelserror-logging- Use PSR-3 logging
3. Performance (HIGH)
perf-opcache-enabled- Enable OPcacheperf-autoloading- Use Composer autoloaderperf-string-interpolation- Prefer interpolationperf-generators-memory- Use generators for large data
4. Type Safety (MEDIUM-HIGH)
types-strict-types- Declare strict_types=1types-return-types- Always declare return typestypes-nullable-types- Use ?Type for nullabletypes-union-types- Use union types
5. OOP Patterns (MEDIUM)
oop-final-classes- Prefer final classesoop-interface-segregation- Small interfacesoop-dependency-injection- Inject dependencies
6. PSR Standards (MEDIUM)
psr-coding-style- Follow PSR-12psr-autoloading- Use PSR-4psr-http-messages- Use PSR-7
7. Modern PHP (LOW-MEDIUM)
modern-constructor-promotion- Use property promotion
How to Use
Read individual rule files for detailed explanations and code examples.
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です