I had 5-30 seconds of responses from Symfony2 by default. Now it is ~ 500 ms in dev environment.
Then I changed the following things in php.ini :
- set
realpath_cache_size = 4M (or more) XDebug disabled completely (test with phpinfo )- realpath_cache_ttl = 7200
- enabled and correctly installed
OPcache (or APC) - restarted apache to reload php.ini
And voilá, the answers have passed less than 2 seconds in dev mode! Hope this helps.
To: 6779 ms 
After: 1587 ms

Symfony2 reads classes from thousands of files and a slow process. When using a small cache of the real PHP path, the file paths must be resolved one after another every time a new request is created in the dev environment, if they are not in the PHP real path cache. By default, for symfony2, the realpath cache is too small. In prod, this is of course not a problem.
Cache Metadata:
Metadata caching (e.g. matching) is also very important to further improve performance:
doctrine: orm: entity_managers: default: metadata_cache_driver: apc query_cache_driver: apc result_cache_driver: apc
For this you need to enable APCu . It is APC without a bytecode cache, since OPcache already caching operation code. OPcache is built in with PHP 5.5.
---- After: 467 ms ----
(in a prod environment, the same answer is ~ 80 ms)

Please note: this project uses 30+ packages and contains tens of thousands of lines of code, almost hundreds of its own services, so 0.5s works well in the local Windows environment, using only a few simple optimizations.
Dénes Papp Jul 29 '13 at 0:54 on 2013-07-29 00:54
source share