php-domain-best-practices

Enforces PHP strict-types, use-statement ordering, and naming conventions in Laravel backend classes.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/jhannka/php-skills --skill php-domain-best-practices-jhannka
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-domain-best-practices
Source: https://github.com/jhannka/php-skills/tree/main/skills/php-domain-best-practices
Command: npx skills add https://github.com/jhannka/php-skills --skill php-domain-best-practices-jhannka

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? PHP codebases drift into inconsistent style when developers forget strict_types declarations, inline fully qualified class names, or mix naming languages across files. This Skill gives an AI agent a single set of enforceable conventions so every new or refactored PHP class follows the same rules. ## Core Features & Use Cases - Strict Types Enforcement: Requires declare(strict_types=1); immediately after the opening <?php tag in every PHP file, including files generated via Artisan. - Use-Statement Rules: Mandates importing classes with use statements instead of inline FQCNs, with a defined ordering (Illuminate facades, Cms classes, App classes, Exceptions, Traits/Interfaces). - Naming Language Discipline: New variables, methods, and classes are named in English while existing Spanish schema and model names (e.g. CiudadRepo, departamento_id) are preserved as-is. - Use Case: When asking an agent to create a new service class in a Laravel repo, the agent automatically adds the strict_types declaration, orders imports correctly, and names new methods in English without touching legacy Spanish identifiers. ## Quick Start Apply the PHP conventions skill when creating or refactoring any PHP class in this Laravel repository so it follows strict-types, import ordering, and naming rules.

Frequently Asked Questions about php-domain-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce strict_types in every PHP file?

Add declare(strict_types=1); immediately after the opening <?php tag in every PHP file. Files generated via Artisan do not include it automatically, so it must be added manually after generation.

How should use statements be ordered in a Laravel PHP file?

Order imports as: Illuminate framework facades first, then Cms classes, then App classes, then Exceptions, and finally Traits and Interfaces. Always import classes with use statements rather than referencing fully qualified class names inline.

Should I rename existing Spanish database columns and models to English?

No. Keep existing Spanish names like Ciudad, Perfil, and departamento_id when referencing current schema or models, since renaming them is a separate large change. Only new variables, methods, and classes you introduce should use English names.

Can I use inline fully qualified class names like \Carbon\Carbon::now()?

No. Import the class at the top of the file with use Carbon\Carbon; and then call Carbon::now(). This applies to any FQCN, not just framework classes, keeping files readable and imports centralized.

When should these PHP conventions be applied?

Apply them whenever creating or refactoring PHP classes in the Laravel repository, including services, repositories, and Artisan-generated files. They are global conventions, not limited to a single domain layer.