Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My tips for faster ZF (try from top to bottom):</p> <h3>Optimize include path</h3> <ul> <li>zend path first</li> <li>models next</li> <li>rest at the end</li> </ul> <h3>Use PHP 5.5 with OPCache enabled [NEW]</h3> <ul> <li>I can't stress this enough</li> <li>gains around 50%</li> </ul> <h3>Cache table metadata</h3> <ul> <li>should be cached even if no other caching is needed</li> <li>one of our application performance improved by ~30% on Oracle server ;)</li> </ul> <h3>Favour viewHelpers over using action() <em>view helper</em></h3> <ul> <li>create view helper that access your model</li> <li>or pass only the data from model and format them with view helpers</li> </ul> <h3>Use classmap autoloader</h3> <ul> <li>since ZF1.11</li> <li>preferably with stripped require_once calls</li> </ul> <h3>Minimize path stacks</h3> <ul> <li>there are a lot of path stacks in ZF <ul> <li>form elements</li> <li>view helpers </li> <li>action helpers</li> </ul></li> <li>each path stack lookup means stat call = performance loss</li> <li>default classes are more and more expensive with every path on stack</li> </ul> <h3>Strip require_once</h3> <ul> <li>strip require_once from Zend's classes in favour of autoloading <a href="http://framework.zend.com/manual/1.12/en/performance.classloading.html#performance.classloading.striprequires.sed" rel="nofollow">using find &amp; sed</a></li> </ul> <h3>Favour render() over partial() view helper</h3> <ul> <li>no new view instance is created</li> <li>you need to set variables outside the rendered view scope, inside the main view!</li> <li>you can also replace <em>partialLoop()</em> with <em>foreach + render()</em></li> </ul> <h3>Cache anything possible</h3> <ul> <li>small chunks that require lot of work and change seldomly (like dynamic menus)</li> <li>use profiler to find low-hanging fruit <ul> <li>what you <em>think</em> is slow may not really be so slow</li> </ul></li> <li>cache everything that can have cache set statically <ul> <li>see manual - <code>Zend_Locale::setCache(), Zend_Currency::setCache(), Zend_Db_Table::setDefaultMetadataCache(), configs...</code></li> </ul></li> </ul> <h3>Never use <em>view helper</em> action() or <em>action helper</em> actionStack()</h3> <ul> <li>Never use them unless 100% needed - for example for complicated data output, but mind the performance loss they pose</li> <li>They create whole new dispatch loop and are performance killers!</li> </ul> <h3>Disable viewRenderer</h3> <ul> <li><a href="http://till.klampaeckel.de/blog/archives/92-Zend-Framework-Slow-automatic-view-rendering.html" rel="nofollow">take care of view rendering yourself</a></li> </ul> <h3>Try my superlimunal plugin</h3> <ul> <li>it merges included classes to one long file to minimize stat calls</li> <li>get if from <a href="https://github.com/tomasfejfar/ZF1-superluminal" rel="nofollow">GitHub</a> <ul> <li>it's port from <a href="https://github.com/EvanDotPro/EdpSuperluminal" rel="nofollow">ZF2 version from EDP</a></li> <li>but beware - it's not tested in production yet, use with care</li> </ul></li> <li>measure performance gain <ul> <li>there was a loss for me on slow HDD and all ZF classes in it</li> <li>try minimizing it with <a href="http://php.net/manual/en/function.php-strip-whitespace.php" rel="nofollow">strip whitespace function</a></li> </ul></li> </ul> <h3>Server-side file minification</h3> <ul> <li>It makes sense for really big files - HDD is always the bottleneck</li> <li>Even micro-optimization works fine sometimes <ul> <li>classmap with all ZF classes' paths is HUGE, striping whitespace and replacing long variables with <code>$a</code> and <code>$b</code> brought performance gain when having "dry" opcode cache and HDD under pressure.</li> </ul></li> </ul> <p>Any opcode cache is of course a must have ;) (APC, ZendOptimizer, etc.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload