This question is regarding design pattern(ish) and best practices in project design bearing in mind that SOLID design principles are goals and not rules. It's not Laravel specific but Jeffrey's series on SOLID principles encouraged me to ask here.
My team is rebuilding a project where in several instances a user request performs one action (that they know about) but carries out a chain or other operations (predominantly DB operations) as a consequence. Some of the latter operations may depend on what has happened before - usually to reference an item from the DB.
Overall, the whole operation is not that complex but I get the feeling there could be a better way of executing the process.
One controller in questions looks like this:
public function runProcess(ManagerX $managerX, ManagerY $managerY, etc ...)
{
//...
$valid = $validator->validateStuff();
// maybe set some data required across the upcoming actions...
$result1 = $managerX->doAction1();
$result2 = $managerY->doAction2($result1);
// etc...
return $someKindOfResponse;
}
The controller ends up being 70 lines long. I understand there are no hard and fast rules here but is there a more object orientated way of laying this out or is it just that large operations need to be written out this way?
I've heard of options such as service layers, using repositories etc but at the end of the day, each class/method needs to be called at some point and since some of the methods are re-used in other parts of the app, it seems sensible to keep them as de-coupled as possible.
Any observations or advice would be welcome.