News Feed
Sections




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

Rob Allen:
Injecting configuration into a ZF2 controller
April 30, 2013 @ 09:11:16

Rob Allen has a a new post to his site today showing you how to inject configuration information into a Zend Framework 2 controller via an interface and some initializer settings in the module setup.

One thing you may find yourself needing to do is access configuration information in a controller or service class. The easiest way to do this is to use the ServiceManger's initialiser feature. This allows you to write one piece of injection code that can be applied to multiple objects. It's easier to show this in action!

He includes a sample configuration file (with a setting for "setting_1") and the interface you implement to structure the load request. He then shows how to hook this into the controller and the code needed for the module "getControllerConfig" (or "getServiceConfig" for use with services) to load in the file and set it to the correct object.

0 comments voice your opinion now!
inject configuration controller zendframework2 tutorial file

Link: http://akrabat.com/zend-framework-2/injecting-configuration-into-a-zf2-controller

blog comments powered by Disqus

Similar Posts

99Points.info: Youtube Style Share Button With URL Shortening using CURL, jQuery and PHP

Stuart Herbert's Blog: Can You Secure A Shared Server With PHP + FastCGI?

Master Zend Framework: Make Module Configs Cacheable with the ZF2 Factory Interface

Raymond Kolbe's Blog: DOMPDF in ZF2

IBM developerWorks: A step-by-step guide to publishing your own PEAR channels


Community Events





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


opinion laravel community testing language series release install unittest podcast list code introduction interview threedevsandamaybe framework symfony2 developer refactor configure

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