ZF2 – Get controller name into layout/views

ZF2 is out and so is the skeleton. This is adding on top of the skeleton so it should be your best example: Inside Module.php public function onBootstrap($e) { $e->getApplication()->getServiceManager()->get(‘translator’); $e->getApplication()->getServiceManager()->get(‘viewhelpermanager’)->setFactory(‘controllerName’, function($sm) use ($e) { $viewHelper = new View\Helper\ControllerName($e->getRouteMatch()); return $viewHelper; }); $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); } The actual ViewHelper: // … Read more

Zend File Upload and Element Decorators

The File element requires it’s own decorator – Zend_Form_Decorator_File. $this->setElementDecorators(array( ‘File’, ‘Errors’, array(array(‘data’ => ‘HtmlTag’), array(‘tag’ => ‘td’)), array(‘Label’, array(‘tag’ => ‘th’)), array(array(‘row’ => ‘HtmlTag’), array(‘tag’ => ‘tr’)) )); [edit] Have just noticed that you are also using other form elements. After your original code, add: $this->getElement(‘Excel’)->setDecorators( array( ‘File’, ‘Errors’, array(array(‘data’ => ‘HtmlTag’), array(‘tag’ => … Read more

Getting Zend_Navigation menu to work with jQuery’s Fisheye

I haven’t seen the way yet either in terms of making a custom renderer. Here’s what I ended up doing though: First, instead of rendering the default menu() call, create a partial to render into: // menu.phtml is partial, cms is module $partial = array(‘menu.phtml’, ‘cms’); $this->navigation()->menu()->setPartial($partial); echo $this->navigation()->menu()->render(); Then (from the docs), you can … Read more

DOMPDF doesn’t work with external css file

This has in fact nothing to do with Zend Framework, but you need to supply DomPDF the right path to load the “external” files from. $dompdf = new DOMPDF(); $dompdf->setBasePath(realpath(APPLICATION_PATH . ‘/path/to/css/’)); $dompdf->loadHtml($html); $dompdf->render(); See also the manual of DomPDF for this feature.

php, mysql – Too many connections to database error

There are a bunch of different reasons for the “Too Many Connections” error. Check out this FAQ page on MySQL.com: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html Check your my.cnf file for “max_connections”. If none exist try: [mysqld] set-variable=max_connections=250 However the default is 151, so you should be okay. If you are on a shared host, it might be that other … Read more

session_start() takes VERY LONG TIME

session_start (with sessions stored in files) is blocking in PHP, so this issue will appear if you try to start several server sessions for the same browser session (AJAX or multiple browser tabs/windows). Each session_start will wait until the other sessions have been closed. See here: http://konrness.com/php5/how-to-prevent-blocking-php-requests/ Try changing from files to database storage of … Read more