Heya! Sorry for cross-posting, but I replied this some time ago at http://stackoverflow.com/questions/15136925/missing-examples-for-zend-framework-2-tutorial-learning-dependency-injection
The answer above is valid when using Zend\Di, of course. You can use the `preference` setting to pick a specific `BarInterface` implementation when one is requestede: http://stackoverflow.com/questions/12426744/servicelocatorawareinterface-confuses-the-di-container-when-running-module-tests Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 16 March 2013 22:18, mbneto <[email protected]> wrote: > Hi, > > I found just one documentation about the Zend DIC but I could not find how > to inform which concrete class should it create based on an interface > > Ex. > > class Foo > { > public function __construct(BarInterface $bar) > { > } > } > > class Bar implements BarInterface > { > public function __construct($someArg) > { > } > } > > I want to create a new instance of Foo using the DIC. How can I set this? > > $foo = $dic->get('Foo', ?) > > Thanks, >
