laravel-clean-architecture
1
总安装量
1
周安装量
#42416
全站排名
安装命令
npx skills add https://smithery.ai
Agent 安装分布
antigravity
1
Skill 文档
Laravel Clean Architecture
Priority: P1 (HIGH)
Structure
app/
âââ Domains/ # Logic grouped by business domain
â âââ {Domain}/
â âââ Actions/ # Single use-case logic
â âââ DTOs/ # Immutable data structures
â âââ Contracts/ # Interfaces for decoupling
âââ Providers/ # Dependency bindings
Implementation Guidelines
- Domain Grouping: Organize code by business domain (e.g.,
User,Order) instead of framework types. - DTOs: Use
readonlyclasses to pass data between layers; avoid raw arrays. - Action Classes: Wrap business logic in single-purpose classes with
handle()orexecute(). - Repository Pattern: Abstract Eloquent queries behind interfaces for easier testing.
- Dependency Inversion: Bind Interfaces to implementations in
AppServiceProvider. - Model Isolation: Keep Eloquent models lean; only include relationships and casts.
Anti-Patterns
- Domain Leak: No Eloquent in Controllers: Use DTOs/Actions to bridge layers.
- Array Overload: No raw data arrays: Use typed DTOs for structured data.
- Service Bloat: No God Services: Break down large services into granular Actions.
- Infrastructure Coupling: No hard dependencies: Depend on abstractions, not concretions.