php-laravel
Installation
SKILL.md
PHP & Laravel Development
Code Style
declare(strict_types=1)in every file- Happy path last -- handle errors/guards first, success at the end. Use early returns; avoid
else. - Comments only explain why, never what. Never comment tests. If code needs a "what" comment, rename or restructure instead.
- No single-letter variables --
$exceptionnot$e,$requestnot$r ?stringnotstring|null. Always specifyvoid. Import classnames everywhere, never inline FQN.- Validation uses array notation
['required', 'email']for easier custom rule classes - Static analysis: run PHPStan at level 8+ (
phpstan analyse --level=8). Aim for level 9 on new projects. Use@phpstan-typeand@phpstan-paramfor generic collection types.
Modern PHP (8.4)
Use these when applicable -- do not add explanatory comments in generated code (Claude and developers know them):
- Readonly classes and properties for immutable data
- Enums with methods and interfaces for domain constants
- Match expressions over switch
- Constructor promotion with readonly
Related skills