mardi 15 mars 2016

PHP Service: Singleton or Static

I want to separate my data manipulation code from the controller by making a service.

I'm asking myself if it's better to do something like Service::getInstance()->function() (Singleton) or simply Service::function() (Static)

Normally, I will make a singleton service and people say that it's more testable.

But in my case, the service will use something like Article::find($id). So my question is: is it necessary to make a singleton if this singleton use static method? I think that in this case, the testability will change nothing. Is it right? I want to do it in the right way so I need your help.

thanks a lot :)

Aucun commentaire:

Enregistrer un commentaire