> php-best-practices
PHP best practices, PSR standards, and code quality guidelines. Use when writing PHP following PSR standards, SOLID principles, or improving code quality. (triggers: **/*.php, psr-12, camelCase, PascalCase, dry, solid)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/php-best-practices?format=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
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)