php

Php

9 community-ranked rules

9 rules
Move to Config3/10
2

Write rules for yourself that prevent the same mistake

This belongs in automated testing or linting pipelines, not in agent instructions.

Agent Workflow
Self-Improvement Loop
Vague rule
Move to Config3/10
1

Follow PSR-12 coding style. Use `camelCase` for methods, `PascalCase` for classes, `UPPER_CASE` for constants.

This belongs in a php-cs-fixer config with 'PSR-12' ruleset or PHP_CodeSniffer with PSR12 standard, not in agent instructions.

Style Guide
PHP Defaults
Helpful5/10
1

Use plan mode for verification steps, not just building

Adds minimal value over the 0922494eee667d5d rule as it restates plan mode use without distinct actionable guidance.

Agent Workflow
Plan Mode Default
Vague ruleNear duplicate
Helpful6/10
1

Validate all external inputs at system boundaries. Trust nothing from users, APIs, or files.

Saves time by specifying all three untrusted input sources (users, APIs, files) as requiring validation at system boundaries.

Architecture
Production Readiness
1

Use strict types: declare `declare(strict_types=1)` at the top of every PHP file — it prevents silent type coercion in function arguments.

Style Guide
PHP Defaults
1

Design a minimal, intuitive public API. Every exported symbol is a commitment — keep the surface area small.

Architecture
Library Architecture
1

Avoid N+1 query patterns — use batch loading, JOINs, or DataLoader patterns.

Performance
Performance Guidelines
1

Use PHP 8.2+ features: readonly classes, enums, named arguments, fibers, union/intersection types.

Style Guide
PHP Defaults
1

Write E2E tests for critical user journeys: signup, login, checkout, core workflows.

Testing
E2E Testing

Have a rule that helps your AI coding agent? Share it with the community.

Suggest a Rule