I have a situation where I have Services that depend on a fair bit of heavy logic that don’t exactly fit into the same Service file. I want to abstract this logic out of the Service file but also want to move it to a place that seems obvious and doesn’t break any Laravel conventions.
I want to keep my code quality high, but this Service is already about 200 lines long and don’t want to tac another 200 extra lines on it. These 200 lines or so of Logic also are a bit too heavy and large to be considered a Helper either since they’re usually more bite sized reusable functions, this logic won’t be reusable it’s very specific for this Service.
I’ve brainstormed a couple of methods to tackling this mainly creating a “ServiceHelper” (placeholder name) folder outside of the Laravel Service Directory and sticking the logic in there in the form of Helpers. I’ve also looked up Sub-Services and Supporting Classes but none of these seem to really match exactly what I want.
So I’ve basically this:
└── App
└── Services
├── MyService.php
└── MyServiceLogic.php
My Idea of the “ServiceHelper” folder would look like so:
└── App
├── ServiceHelper
│ └── MyServiceLogic.php
└── Services
└── MyService.php
Just wondering if anyone has run into a similar situation could give some advise on what they done. Maybe it is a standard in Laravel if you have a Service that depends on extra logic you make a Sub-Service or a Service Helper inside the Services folder, but just my interpretation is that the Services folder mainly only contains code that is designed to be reused and code that isn’t reused shouldn’t be overly heavy either. But it’s also paradoxical at the moment since neither solutions are satisfying me.