laravel:controller-cleanup

Reduce controller bloat using Form Requests for auth/validation, small Actions/Services with DTOs, and resource/single-action controllers

jpcaparas/superpowers-laravel108 installsMITSynced Aug 26

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: laravel:controller-cleanup
description: Reduce controller bloat using Form Requests for auth/validation, small Actions/Services with DTOs, and resource/single-action controllers
license: MIT
---

# Controller Cleanup

Keep controllers small and focused on orchestration.

## Move auth/validation to Form Requests

- Create a Request class (e.g., `StoreUserRequest`) and use `authorize()` + `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

```php
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

More Backend Frameworks skills

← All Backend Frameworks skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY