ZF2 ServiceManager Custom ViewHelpers

The previous article explains how the ‘Zend\Mvc\Service\ModuleManagerFactory‘ sets initializers that gather information from certain keys in the configuration. A ‘ViewHelperManager’ is configured to read the ‘view_helpers’ key. Which expects regular ServiceConfiguration config.

We have seen that the Mvc  ‘ServiceListenerFactory‘ maps the default ‘ViewHelperManager’ to ‘Zend\Mvc\Service\ViewHelperManagerFactory‘. This class does not only have a default helper map, which includes a HelperConfig that will add a factory under the ‘navigation’ key, but also extends from ‘Zend\View\HelperPluginManager‘, which in turn contains the configuration for more ViewHelpers.

And it doesn’t stop there.

Continue reading »

ZF2 ServiceManager configuration walkthrough

ZF2 is all about extensibility, and the new ServiceManager and Config make it very easy, if you know how. Extensibility comes with some complexity, and it may be a bit harder to try and trace where everything is going, especially when using events.

With the ZF2 Configuration manager and Service Locator configurations, it’s not always as simple to know where to find the defaults, and how to best override them. This post might remind you of the factoryfactoryfactoryfactory post from joelonsoftware

I wanted to implement some custom navigation stuff and soon began to wonder how the config works, and how I can manipulate it to inject my custom view helpers or navigation pages. This post will cover the buildup of the service manager, and I plan to do some follow up posts to go into some of the main service factories.

Continue reading »

Domain layer and ZendFramework2 using Zend\ServiceManager

UPDATE: ctrllib has been implemented in CtrlSkeleton, providing easy database management for Doctrine entities and implemented ViewHelpers for Twitter Bootstrap.

In the previous article I gave a brief overview of how the current implementation of my Domain Layer looks. To be able to use these classes inside ZF2 controllers I used a custom ServiceManager Factory. This custom ServiceManager will take care of Dependency Injection and register configured DomainServices

Continue reading »