Using sfService For Object Creation in General

6 views
Skip to first unread message

iSac

unread,
Aug 21, 2010, 4:23:18 PM8/21/10
to Symfony Components
I've been thinking about using sfServiceContainerBuilder, or a small
extension of it, to do most of my object creation, even in situations
that aren't (I don't think) normally thought of as fitting into the DI
use case, and I'm wondering if this is the right idea, or if doing so
is overkill (or if there is some other pattern I should be looking
at).

It seems like a huge benefit of using sfService* is the centralization
of object construction (in fact, the DI seems a side benefit of that).
For instance, the ability to swap in and out the concrete class
instantiated for all instances, to force certain configurations for
all instances, etc, in one place seems like a good idea outside of
injecting session storage, mail transport, or other dependencies.

So my kind of abstract question is: would using
sfServiceContainerBuilder to build most of my objects, even ones
without dependencies, be considered a "good idea"? I guess it seems to
me like a good and powerful idea in theory, but my relative lack of
experience makes me worry I'm jumping into a wading pool head first.
Many thanks in advance for any advice anyone can give.
Reply all
Reply to author
Forward
0 new messages