News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin Schroeder's Blog:
ZF2 Dependency Injection - Multiple Object Instances
April 30, 2012 @ 12:15:34

Kevin Schroeder has a quick new post about using dependency injection in Zend Framework 2 applications using multiple object instances.

When you work with the ZF2 Dependency Injection Container (DiC) when you make multiple requests for an instance of an object you will get the same object back each time. [...] But what if you want the injection benefits of the DiC but don't want to share the object? Use the DiC's newInstance method instead with the third parameter being false.

He includes code examples of requesting the object both ways - the usual way that returns the same object and the alternative that passes in a "false" value, complete with a debug output of each object proving they're different.

0 comments voice your opinion now!
zendframework2 dependency injection dic multiple object parameter false


blog comments powered by Disqus

Similar Posts

SaniSoft Blog: Multiple validation rules per model field while baking

Bill Staples' Blog: IIS7 Patch for Windows Vista fixes CGI/PHP apps - multiple response headers

PHPMaster.com: What's New in Zend Framework 2

Joshua Thijssen's Blog: LAMP-stack? Forget it! Itís a LAMPGMVNMCSTRAH-stack now...

MaltBlue.com: Use RouteMatch in Zend Framework 2 For Easy Routing


Community Events

Don't see your event here?
Let us know!


interview podcast opinion laravel5 release wordpress library laravel conference voicesoftheelephpant framework language series development introduction extension psr7 unittest community api

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework