php - Does it make sense to have singleton service classes in Laravel?
Get the solution ↓↓↓There is a class in my project, for example CalculationService. This class has methods that manipulates data in it's way. This class is injected in many places through application using the Laravel DI. Does it make sense to register it as singleton to avoid multiple instances through the application?
class CalculationService {
}
class CarController extends Controller
{
public function __construct(CalculationService $service)
{
$this->calculationService = $service;
}
public function show()
{
$this->calculationService->multiply();
...
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: can't write image data to path
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.