Zend Framework 2: performance optimization

Nowadays the performance of a website is very very important for everything, user experience, Google and so on.

I have found nice PDF from one PHP conference in 2014 by Gary Hockin, this guy is Zend Framework contributor and made these awesome instructions how to optimize our Zend Framework 2 and how to use best practices.

This is the file Maximising Performance in Zend Framework 2

Some additions from me:

  • Siege – how to measure your performance.
  • Xdebug
  • View template map & Classmaps
    • For this, I have made simple deploy.sh bash script to do several things, one of them is to generate the template map
      #!/usr/bin/env bash
      
      # Defaults
      projectRootDir=$(pwd)
      GREEN='\033[0;32m'
      NOCOLOR='\033[0m'
      
      # Go to each module folder and execute template_map and classmap generators
      for i in $(ls -d module/*/); do
       # Exclude our base module
       if [ $i == "module/Base/" ]; then
       continue
       fi
      
       # Go to module directory
       cd ${i%%/};
       # Generate the template map and class map running PHP scripts
       printf ${GREEN}
       php ../../vendor/zendframework/zendframework/bin/classmap_generator.php -w
       php ../../vendor/zendframework/zendframework/bin/templatemap_generator.php -w
       echo "---"
       printf ${NOCOLOR}
       # Back to Root dir
       cd $projectRootDir;
      done
      
      # Do your other stuff, run migrations, clear cache, composer update etc.

That’s it, if you have any comments, your own ideas for optimizations or anything else, please write in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *