laravel:controller-cleanup

📁 jpcaparas/superpowers-laravel 📅 Jan 21, 2026
25
总安装量
14
周安装量
#14554
全站排名
安装命令
npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:controller-cleanup

Agent 安装分布

claude-code 12
gemini-cli 8
codex 6
windsurf 5
cursor 5

Skill 文档

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