plugins/laravel-expert/skills/solid-php/SKILL.md
SOLID principles for Laravel 13 and PHP 8.3+. Files < 100 lines, interfaces separated, PHPDoc mandatory. Auto-detects Laravel and FuseCore architecture.
npx skillsauth add fusengine/agents solid-phpInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
After implementation, run fuse-ai-pilot:sniper for validation.
Before writing ANY new code:
FuseCore/Core/App/Services/, FuseCore/Core/App/Traits/, FuseCore/[Module]/App/Contracts/| Files Detected | Architecture | Interfaces Location |
|----------------|--------------|---------------------|
| FuseCore/ directory | FuseCore Modular | FuseCore/[Module]/App/Contracts/ |
| module.json in modules | FuseCore Modular | FuseCore/[Module]/App/Contracts/ |
Verification: php artisan --version → Laravel 13.x
Structure: Always FuseCore modular. Shared in FuseCore/Core/App/.
New code needed?
├── HTTP validation → FuseCore/[Module]/App/Http/Requests/
├── Single action → FuseCore/[Module]/App/Actions/
├── Business logic → FuseCore/[Module]/App/Services/
├── Data access → FuseCore/[Module]/App/Repositories/
├── Data transfer → FuseCore/[Module]/App/DTOs/
├── Interface → FuseCore/[Module]/App/Contracts/
├── Event → FuseCore/[Module]/App/Events/
└── Authorization → FuseCore/[Module]/App/Policies/
| Need | Pattern | Location | Max Lines | |------|---------|----------|-----------| | HTTP handling | Controller | Controllers/ | 50 | | Validation | FormRequest | Requests/ | 50 | | Single operation | Action | Actions/ | 50 | | Complex logic | Service | Services/ | 100 | | Data access | Repository | Repositories/ | 100 | | Data structure | DTO | DTOs/ | 50 | | Abstraction | Interface | Contracts/ | 30 |
FuseCore/[Module]/App/Contracts/ # Module interfaces ONLY
├── UserRepositoryInterface.php
└── PaymentGatewayInterface.php
FuseCore/Core/App/Contracts/ # Shared interfaces
/**
* Create a new user from DTO.
*
* @param CreateUserDTO $dto User data transfer object
* @return User Created user model
* @throws ValidationException If email already exists
*/
public function create(CreateUserDTO $dto): User
| Topic | Reference | When to consult | |-------|-----------|-----------------| | SOLID Overview | solid-principles.md | Quick reference all principles | | SRP | single-responsibility.md | File too long, fat controller/model | | OCP | open-closed.md | Adding payment methods, channels | | LSP | liskov-substitution.md | Interface contracts, swapping providers | | ISP | interface-segregation.md | Fat interfaces, unused methods | | DIP | dependency-inversion.md | Tight coupling, testing, mocking | | Anti-Patterns | anti-patterns.md | Code smells detection | | Decisions | decision-guide.md | Pattern selection | | PHP 8.5 | php85-features.md | Modern PHP features | | Structure | laravel12-structure.md | Standard Laravel | | FuseCore | fusecore-structure.md | Modular architecture |
| Template | When to use | |----------|-------------| | code-templates.md | Service, DTO, Repository, Interface | | controller-templates.md | Controller, Action, FormRequest, Policy | | refactoring-guide.md | Step-by-step migration from legacy code |
| Anti-Pattern | Detection | Fix |
|--------------|-----------|-----|
| Files > 100 lines | Line count | Split into smaller files |
| Controllers > 50 lines | Line count | Extract to Service |
| Interfaces in impl files | Location | Move to FuseCore/[Module]/App/Contracts/ |
| Business logic in Models | Code in model | Extract to Service |
| Concrete dependencies | new Class() | Inject via ModuleServiceProvider |
| Missing PHPDoc | No doc block | Add documentation |
| Missing strict_types | No declare | Add to all files |
| Fat classes | > 5 public methods | Split responsibilities |
| Duplicated logic | Same code in 2+ files | Extract to Service/Trait |
| No Grep before coding | Creating without search | Grep codebase first |
| DO | DON'T |
|----|-------|
| Use constructor property promotion | Use property assignment |
| Depend on interfaces | Depend on concrete classes |
| Use final readonly class | Use mutable classes |
| Use declare(strict_types=1) | Skip type declarations |
| Split at 90 lines | Wait until 100 lines |
| Use DTOs for data transfer | Use arrays |
Laravel 13 exige PHP 8.3 (était 8.2 sur L12). Fonctionnalités SOLID-friendly :
readonly classes : final readonly class UserDto (immutabilité totale)const int MAX_RETRIES = 3;#[\Override] attribute : déclare explicitement une override de méthode parente (catch typos)json_validate() natif (plus rapide que json_decode + try/catch)$class::{$name}use Override;
final readonly class PaymentService implements PaymentContract
{
public const int DEFAULT_TIMEOUT = 30;
public function __construct(
private StripeClient $stripe,
private LoggerInterface $logger,
) {}
#[Override]
public function process(PaymentDto $payment): PaymentResult
{
// ...
}
}
final readonly class pour tous les DTO/Value Objects#[\Override] sur toute méthode héritée (CI catch)const string ROLE = 'admin';)development
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.