That certainly works, but it seems to add an awful lot of clutter – a separate 
factory class for every service. My application offers a lot of different 
options, so this would add hundreds of files and require PHP to do twice as 
much autoloading (which I realize isn’t that expensive, but it has to add up at 
some point). I considered putting a static factory method in each class to cut 
down on clutter, but this doesn’t seem like good design – it couples things 
unnecessarily. Having stand-alone factory classes that group together related 
objects seems like the most attractive option from an organizational 
perspective. Sounds like it may not be practical, and I know you’re the expert 
– but I would be curious to hear if anyone else has successfully approached 
this from another angle. If not, I’ll get to work moving all my factories 
around a second time. ☺

- Demian

From: Matthew Weier O'Phinney [mailto:[email protected]]
Sent: Tuesday, March 11, 2014 7:32 PM
To: Demian Katz
Cc: Zend Framework General
Subject: Re: [fw-general] Configuration merging and callables

Use classes that implement __invoke() instead, and reference the class name. 
The SM is smart enough to autoload these when requested, making them a more 
robust solution than array callbacks - particularly for the use car of 
overriding.

Reply via email to