zf2-logo-markBased on this video from Gary Hockin (http://blog.hock.in/2014/05/14/maximising-performance-in-zf2-phpuk/) and tips through Alan Seiden I have written this guide to help anyone speed up their ZF2 app. The biggest improvement I have seen so far has been going from the standard autoloader to the classmapautoloader. My load time has gone from 700-900ms (based on zenddevelopertools) to 100-300ms. As a guideline you want your pages to try and load 200ms or less on average.

1. Cache! You can cache your module.config.php to help improve response time. Here is a great article from Rob Allen on how to not only cache your config, but also only have it turn on in production. Caching your config when you are still making changes to it can cause quite the headache!

2. Do not use the standard autoloader. Generating a classmap for each module for the BIGGEST performance increase. It can be a bit manual because you will need to go into each module root directory to run it, but the end result is worth it. There is supposedly a way to do this with composer but I have not done it. I also develop on my Mac so I did this piece on my personal computer. I went into the module directory
[code]cd /modulename
php classmap_generator.php –overwrite[/code]

The -overwrite will take care if one already exists. Full instructions here:

3. Always make sure you have a favicon.ico (as well as auto-requested files by the browser). Not having these files forces the framework to double the amount of calls for each little image file and slows down your website. The skeleton app has one built in to help out with this.