Symfony project running slowly locally

I have had this problem for quite some time, but it’s slower and slower to display a simple page of my Symfony 2 project.

This is my development environment:

  • Wampserver 2.2 with PHP 5.3.13, MySQL 5.5.24 and Apache 2.2.22
  • Symfony 2.7
  • Netbeans 8.1

I'm really not sure if this comes from Symfony, although this is more obvious with the symfony project (4-5 minutes to display the page).

Even the phpmyadmin call from the wampserver server is long.

No problems with memory, processor or disk. Using the resource manager to check everything seems fine.

These are the Apache logs. I have kilometers:

PHP Fatal error: maximum runtime 90 seconds exceeded in C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes.php on line 5270, referent: http: //localhost/MyProject/web/app_dev.php/ myURL? init
[Thu May 12 14:11:28 2016] [error] [client 127.0.0.1] PHP Stack trace :, referer: http: //localhost/MyProject/web/app_dev.php/myURL? Init
[Thu May 12 14:11:28 2016] [error] [client 127.0.0.1] PHP 1. Monologue \ Handler \ AbstractHandler β†’ __ destruct () C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes. php: 0, referer: http: //localhost/MyProject/web/app_dev.php/myURL? init
[Thu May 12 14:11:30 2016] [error] [client 127.0.0.1] PHP Fatal error: maximum execution time exceeded by 90 seconds in C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes.php on line 5270, referent: http: //localhost/MyProject/web/app_dev.php/myURL? init [Thu May 12, 14:11:30 2016] [error] [client 127.0.0.1] PHP Stack trace :, referer: http: //localhost/MyProject/web/app_dev.php/myURL? init [Thu May 12 14:11:30 2016] [error] [client 127.0.0.1] PHP 1. Monologue \ Handler \ AbstractHandler β†’ __ destruct () C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes. php: 0, referer: http: //localhost/MyProject/web/app_dev.php/myURL? init [Thu May 12 14:11:32 2016] [error] [client 127.0.0.1] PHP Fatal error: maximum execution time 90 seconds exceeded in C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes.php on line 5270, referent: http: //localhost/MyProject/web/app_dev.php/myURL? Init [Thu May 12, 14 : 11: 32 2016] [error] [client 127.0.0.1] PHP Stack trace :, referer: http: //localhost/MyProject/web/app_dev.php/myURL? Init [Thu May 12 14:11:32 2016] [error] [client 127.0.0.1] PHP 1. Monologue \ Handler \ AbstractHandler β†’ __ destruct () C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes. php: 0, referer: http: //localhost/MyProject/web/app_dev.php/myURL? init [Thu May 12 14:13:04 2016] [error] [client 127.0.0.1] PHP Fatal error: maximum execution time 90 seconds exceeded in C: \ wamp \ www \ MyProject \ app \ cache \ dev \ classes.php on line 5270, referent: http: //localhost/MyProject/web/app_dev.php/myURL? init

Does anyone have an idea of ​​what I can do ... I've already reinstalled my software several times, but it doesn't change anything

Thanks for the ideas and any help.

+5
source share
2 answers

Based on the comments under the question, we came to the answer that the main reason is XDebug, which usually has a significant impact on PHP performance.

In your team, you wrote that the Symfony profiler now shows 3-6 seconds, but in practice it takes a lot more. This means that PHP itself is probably not the only problem.

I would suggest exploring the browser developer tools (Firebug, etc., depending on the browser you are using) and check the timeline on the Network tab. Perhaps this will give you additional information on where to look for the cause.

For my local computer, it usually takes PHP about a second (on dev env and depending on the state of the cache and on which page) to run Symfony.

+3
source

What I did to speed up symfony runtime in dev mode on my local machine:

  • Install PHP 7. *, it really improves performance.
  • PHP extension for Opcache included with PHP
  • Set realpath_cache_size to 4048k
  • Install redis and enable the metadata cache in the doctrine configuration. Remember that every time you add / change entity files, you must clear the red cache manually. It is worth it that it increases boot time by about 70-100 ms in dev mode.
  • Run composer dump-autoload --optimize to create a class map.

I had about 700-1000 ms boot time in dev mode before optimization, and now it is 250-350.

Of course, the numbers will be different on your machine.

+2
source

All Articles