0026-laravel-controller-cleanup

Refactor Laravel controllers by extracting logic into Form Requests and Actions.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0026-laravel-controller-cleanup
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: 0026-laravel-controller-cleanup
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0026-laravel-controller-cleanup
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0026-laravel-controller-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel controllers can grow bloated when they handle authorization, validation, and business logic in one place, making routes harder to maintain and test.

Core Features & Use Cases

  • Move auth/validation into Form Requests: Centralize authorization and validation rules in dedicated Request classes so controller methods stay orchestration-only.
  • Extract business logic to Actions/Services with DTOs: Encapsulate one responsibility per Action or a larger workflow per Service, passing DTOs to avoid leaking framework concerns.
  • Prefer resource or single-action controllers: Use resource controllers for standard CRUD and invokable controllers for single-purpose endpoints.

Quick Start

Ask an AI to refactor the target controller by extracting validation into a Form Request, moving the core logic into an Action/Service that receives a DTO, and converting the controller to the appropriate resource or invokable style.

Frequently Asked Questions about 0026-laravel-controller-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep Laravel controllers lean and focused?▼

To keep Laravel controllers lean, shift authorization and validation into Form Request classes and extract business logic into Action or Service classes using Data Transfer Objects, ensuring controller methods only orchestrate the workflow.

What is the best way to move validation logic out of a Laravel controller?▼

The best way to move validation out of a Laravel controller is by creating a Form Request class, defining your authorization and rules methods there, and then type-hinting that custom Request object in your controller method signature.

When should I use a resource controller versus an invokable controller in Laravel?▼

Use a Laravel resource controller for standard REST CRUD endpoints to handle all default HTTP verbs, and use an invokable single-action controller for one-off route handlers or single-purpose endpoints that only need a single __invoke method.

How do I pass data to Laravel Actions or Services without leaking framework concerns?▼

Pass data to Laravel Actions or Services by converting validated request data into Data Transfer Objects, ensuring your business logic classes receive plain structured objects instead of direct HTTP request instances.

Can I refactor a bloated Laravel controller to use DTOs and Form Requests?▼

Yes, you can refactor a bloated Laravel controller by extracting validation into a Form Request, moving the core logic into an Action or Service that receives a DTO, and converting the controller to a resource or invokable structure.