Optimising the Zend Framework ?

Answer

down vote accepted

My tips for faster ZF (try from top to bottom):

Optimize include path

  • zend path first
  • models next
  • rest at the end

Use PHP 5.5 with OPCache enabled [NEW]

  • I can't stress this enough
  • gains around 50%

Cache table metadata

  • should be cached even if no other caching is needed
  • one of our application performance improved by ~30% on Oracle server ;)

Favour viewHelpers over using action() view helper

  • create view helper that access your model
  • or pass only the data from model and format them with view helpers

Use classmap autoloader

  • since ZF1.11
  • preferably with stripped require_once calls

Minimize path stacks

  • there are a lot of path stacks in ZF
    • form elements
    • view helpers
    • action helpers
  • each path stack lookup means stat call = performance loss
  • default classes are more and more expensive with every path on stack

Strip require_once

  • strip require_once from Zend's classes in favour of autoloading using find & sed

Favour render() over partial() view helper

  • no new view instance is created
  • you need to set variables outside the rendered view scope, inside the main view!
  • you can also replace partialLoop() with foreach + render()

Cache anything possible

  • small chunks that require lot of work and change seldomly (like dynamic menus)
  • use profiler to find low-hanging fruit
    • what you think is slow may not really be so slow
  • cache everything that can have cache set statically
    • see manual - Zend_Locale::setCache(), Zend_Currency::setCache(), Zend_Db_Table::setDefaultMetadataCache(), configs...

Never use view helper action() or action helper actionStack()

  • Never use them unless 100% needed - for example for complicated data output, but mind the performance loss they pose
  • They create whole new dispatch loop and are performance killers!

Disable viewRenderer

Try my superlimunal plugin

  • it merges included classes to one long file to minimize stat calls
  • get if from GitHub
  • measure performance gain

Server-side file minification

  • It makes sense for really big files - HDD is always the bottlenect
  • Even micro-optimization work fine sometimes
    • classmap with all ZF classes' paths is HUGE, striping whitespace and replacing long variables with $a and $b brought performance gain when having "dry" opcode cache and HDD under pressure.

All zend-framework Questions

Ask your interview questions on zend-framework

Write Your comment or Questions if you want the answers on zend-framework from zend-framework Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---