DEV Community

Discussion on: Single Method Controllers in Laravel

alexparra profile image
Alex Parra

I’ve never did this before... but I do agree that Controllers should be kept lean.
What specific benefits have you found in this pattern? I’m assuming easier debugging but can’t see performance benefits and in my opinion it’s not better developer experience compared to several controllers with a handful of methods that are common to a resource or domain.

dealloc profile image
Wannes Gennar • Edited

You'll place all related controllers in the same namespace (App\Http\Controllers\Users{Register,Invite, ...}UserController.php)

As indicated in this article, it adheres more closely to the single responsibility principle, that a given class should only do a specific thing.

Personally, I'm leaning more and more towards ADR where a single method controller ties in perfectly.
I highly recommend looking into ADR more, and see for yourself where the advantages lie for your project.