I know the title of the question is kind of vague, but I couldn't think of anything cleaner. (And even though it might seem like a ZF question, it really just is a php MVC question.)
I recently migrated a project from ZF2 to ZF3. The main difference was the need of dependency injection in each model & controller. Since I now have injected all dependencies instead of calling them with the serviceLocator (which lazy-loads a service) I'm stuck with a couple of questions.
A couple of controllers now seem really bloated and are instantiating services they wont use. Simply because a different action needs a service the whole controller now instantiates a service. Even though instantiating a service isn't that performance-heavy it still feels like a waste.
My question is, and this basically has been a question of mine since I started working with MVC, how specific would you make a controller? How many actions per controller? Or in this case maybe: how many services per controller?
I'm now even thinking about splitting each controller up, so all actions have their own controller. Is this a good/bad idea?
Any Thoughts?
Aucun commentaire:
Enregistrer un commentaire