Craft Controller

Crafting thin controllers. Traffic cops, not business logic.

attac-t 8f0baf6 2 files · 2.6 KB Updated

File contents

Skill: Craft Controller

"Controllers are traffic cops, not detectives."

The Standard

  1. CRUDDY: index, show, store, update, destroy.
  2. Single-Action: __invoke for complex operations.
  3. Thin: No business logic. Delegate to Actions.
  4. Transaction Owner: DB::transaction() belongs here.

The Anti-Patterns

❌ Don't ✅ Do Why
Business logic in controller Delegate to Action Single responsibility
Raw queries in controller Use QueryBuilder/scopes Controllers don't query
Transaction in Action Transaction in Controller Enables Action composition
Deep conditionals Early returns Flat, readable flow

Real-World Examples

See examples.md.

attac-t/the-foundry/tree/main/plugins/laravel-ddd/skills/craft-controller commit 8f0baf60b4

Frequently asked questions

npx skillmds@latest add attac-t/craft-controller