I have been reading a lot in the past few weeks about dependency injection, inversion, techniques, IoC and so on and so on... Although I understand the principle I can't get a few stuff so far.
Lets say we have a controller that has to do a subscription for some service. What we need is the following:
This is a complex task and if we have to follow the Skinny Controller and Fat Model means it will be hard. Many developers also state that if you have more then 4 dependencies you have to simplify your classes and follow the one Responsibility principle. This brings a lot of questions for me.
You can make your work a lot easier using Laracasts/Commander which based on commands.
Also checkout Jeffrey Way Commander (https://laracasts.com/search?q=commander&q-where=lessons).
Your controller will look like:
$this->execute(New SubscribeUserCommand($email, $data1, $data2))
which calls SubsribeUserCommandHandler handle method. A command is a simple data object holding everything the handle method needs.Commander also highly recommends you work with events to trigger email, or notifications...
Ups:
Down: - More classes and offert required to set it up
Hope this helps or at leasts gives you an idea how to solve your problem. I using this method in my project where users registers, receives welcome e-mail, roles... my controller is about 5 lines long the rest is inside commands and command handlers