PHP

Use when: write or review modern, typed PHP with strict types, clear structure, and safe data handling.

kimtth 06ccd45 1.0 KB Updated

File contents

Goal: modern PHP that is typed, predictable, and secure.

Use for:

  • new PHP code or modernizing legacy scripts
  • reviewing typing, structure, and input handling
  • replacing untyped, procedural sprawl

Workflow:

  1. Declare strict_types and type all signatures.
  2. Use classes, enums, and readonly properties for structure.
  3. Validate and sanitize all external input.
  4. Use prepared statements for every database query.
  5. Throw typed exceptions; avoid silent failure.
  6. Verify with PHPUnit, PHPStan/Psalm, and a linter.

Idioms:

  • constructor property promotion and readonly props
  • enums for fixed sets of values
  • null-safe operator and match expressions
  • PSR autoloading and coding standards

Rules:

  • declare(strict_types=1) in every file
  • never interpolate user input into SQL; use prepared statements
  • escape output for the correct context (HTML, URL, SQL)
  • type everything; let static analysis catch mistakes

kimtth/agent-skill-100-lines-or-less/tree/main/skills/php commit 06ccd4518c

Frequently asked questions

npx skillmds@latest add kimtth/php