php-antipatterns
Installation
SKILL.md
PHP anti-patterns — do not write these
Checks run automatically after each edit. Findings reference the IDs below.
Blockers
- AP-PHP-SEC-001 — No SQL string interpolation. Use
DB::select('… where id = ?', [$id])or the query builder. - AP-PHP-SEC-002 — No
unserialize()on external data. Usejson_decodeorallowed_classes: false. - AP-PHP-SEC-003 — No
exec/shell_exec/backticks with user input. Use Symfony Process with an argv array. - AP-PHP-SEC-004 — Use
{{ $var }}for user data;{!! !!}only for pre-sanitized rich text. - AP-PHP-SEC-006 — Use
Hash::make/password_hashfor passwords;random_bytes/Str::randomfor tokens.
Errors
- AP-PHP-SEC-005 — Never
create($request->all()); use$request->validated()and declare$fillable. - AP-PHP-SEC-007 — Compare secrets and hashes with
hash_equals(), never==or===. - AP-PHP-PERF-001 — Eager-load relations with
->with(); keepModel::shouldBeStrict()enabled in dev. - AP-PHP-PERF-003 — Replace queries-in-loop with
whereIn+ in-memory lookup by key. - AP-PHP-MAINT-002 — Never call
env()outsideconfig/; useconfig('app.key')everywhere else. - AP-PHP-MAINT-004 — Never catch silently; log with context and rethrow or handle specifically.