Long time no ZF2 post, but here is something interesting peace of code that can solve cache problems present in most of the projects. I am assuming that, the reader knows how to create custom cache Factory in ZF2. Step 1. Edit your existing cache factory. See Line 35. namespace Application\Factory; use Application\Factory\CacheProxy; // Or […]
In Zend Framework 2 , layout can be easily changed from module based on controller(name). Step 1. Add in module.config.php file 'controller_layouts' => array( 'MyControllerName' => 'layout/MyControllerName', ), and 'view_manager' => array( //more options 'template_map' => array( 'layout/MyControllerName'=> PATH_TO_TEMPLATE ), ), Step 2. Add in module.php $e->getApplication()->getEventManager()->getSharedManager() ->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); […]
Here is some extended core , helping to auto validate Zend Framework 2 Form. Step 1. Extending Zend Framework 2 Form.
Here is example implementation of a custom view helper script. Step 1. Creating Zend Framework 2 Helper. //file : App_folder/module/Module_name/src/Module_name/View/Helper/SayHello.php namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper; class SayHello extends AbstractHelper{ public function __invoke($name = 'Unnamed'){ return “$name , this is Zend Framework 2 View Helper”; } } Step 2. Registering the Zend Framework 2 Helper. //file : […]