Laravel architecture
Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/laravel-architecture
π§ The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.
npx -y skills add ComeOnOliver/skillshub --skill laravel-architectureAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Core architectural standards for scalable Laravel applications. Use when structuring service layers, repositories, or scalable architecture in Laravel. (triggers: app/Http/Controllers/**/*.php, routes/*.php, controller, service, action, request, container)
SKILL.md
2.4 KB, 444 tokens by cl100k_base, as published. Nobody here has run it
Laravel Architecture
Priority: P0 (CRITICAL)
Structure
app/
βββ Http/
β βββ Controllers/ # Slim (Request/Response only)
β βββ Requests/ # Validation logic
βββ Services/ # Business logic (Optional)
βββ Actions/ # Single-purpose classes (Preferred)
Implementation Guidelines
Controller Responsibilities
- Skinny Controllers: Controller delegates to Action or Service classes; keep controllers focused on mapping requests/responses.
- Dependency Injection: Use constructor DI to inject services or actions. Laravel resolves these via the Service Container.
- No Logic in Routes: Always delegate route closures to controllers; don't use raw Closures for logic.
Business Logic Placement
- Actions: Create app/Actions/CreatePost.php (or similar) β one action per use case β with a single
handle()method. This keeps controllers slim and Create Action class logic focused. - Service Classes: Create app/Services/PaymentService.php for multi-step logic across domains. type-hint interface in controller constructor for clean DI.
- Binding: Bind interfaces in
AppServiceProviderusing$this->app->bind(Interface::class, Implementation::class). - Service Isolation: No Eloquent queries directly in controllers; handle database access within services or actions.
Validation & Requests
- Form Requests: Use
php artisan make:request StoreUserRequestfor Form Requests for validation. - Usage: call $request->validated() in the controller or action for mass assignment.
- Validation Methods: Implement
authorize()andrules(); never use$request->validate()inline.
Anti-Patterns
- No logic in Controllers: Move to Services or Action classes.
- No manual instantiation: Use Service Container via DI.
- No inline
$request->validate(): Favor Form Request classes. - No excessive global helpers: Use class-based logic instead.
References
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.