Laravel controller cleanup
Skill ComeOnOliver/skillshub/skills/noartem/skills/laravel-controller-cleanup
🧠The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.From the repository description
npx -y skills add ComeOnOliver/skillshub --skill laravel-controller-cleanupAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.9 KB, 200 tokens by cl100k_base, as published. Nobody here has run it
Controller Cleanup
Keep controllers small and focused on orchestration.
Move auth/validation to Form Requests
- Create a Request class (e.g.,
StoreUserRequest) and useauthorize()+rules() - Type-hint the Request in your controller method; Laravel runs it before the action
php artisan make:request StoreUserRequest
Extract business logic to Actions/Services
- Create a small Action (one thing well) or a Service for larger workflows
- Pass a DTO from the Request to the Action to avoid leaking framework concerns
final class CreateUserAction {
public function __invoke(CreateUserDTO $dto): User { /* ... */ }
}
Prefer Resource or Single-Action Controllers
- Use resource controllers for standard CRUD
- For one-off endpoints, use invokable (single-action) controllers
Testing
- Write feature tests for the controller route
- Unit test Actions/Services independently with DTOs
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.