0

It's an old-age question. Am crawling at this point. It's year 2023, and yes, I have read tons of post here and elsewhere on the internet pertaining to this issue. It's important I use Xdebug for development. It's really concerning since a job that was to take half a day is now in its fifth day.

I have these settings;

;[xdebug]
;zend_extension=xdebug
xdebug.mode=debug
xdebug.log_level=0
xdebug.client_host=127.0.0.1
xdebug.remote_connect_back=0

Using Xdebug with PhpStorm.

When Xdebug is enabled (uncommented above), pages clock at 6s-25s or more. When disabled, pages come in like a cool breeze at 800ms. Am unable to figure out what is wrong!

Why so slow? What can I do to improve speed? Thank you.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
John Miller
  • 527
  • 4
  • 15
  • Hard to say, really. There is nothing obviously wrong with your provided settings. There will be some delay/slowdown ofc, but nothing major (based on my experience + Xdebug v3 has MUCH less impact on running the code than v2 had) – LazyOne Jan 08 '23 at 14:55
  • Anyway: **1)** `xdebug.remote_connect_back` is Xdebug v2 option -- it does nothing in v3. Please go through https://xdebug.org/docs/upgrade_guide **2)** I suggest you provide your Xdebug settings -- maybe there is something more (configured elsewhere) that you do happen to ignore/miss. Attach the output of `xdebug_info()` captured in the same way where it is slow (a CLI or a web page). **3)** It's possible that some extra code (extra checks/asserts) is run when it sees that Xdebug is present and enabled. If it's some framework, try with any `DEBUG` constants/mode that it may have turned off. – LazyOne Jan 08 '23 at 14:58
  • **4)** Does Xdebug tries to connect to a debug client (PhpStorm in your case) when its enabled? Xdebug log should show this. Is your PhpStorm actively listening for debug connections at that moment? if so -- try to turn that off. **5)** What stuff do you actually run? Maybe it mean to be slower in such a scenario (e.g. collecting code coverage/tracing in your unit tests etc) – LazyOne Jan 08 '23 at 15:01

1 Answers1

1

I had the same problem on an Windows 10 machine with VS-Code (Visual Studio Code) IDE and XAMPP for local Wordpress development: PHP takes 10 to 20 times longer for execution when xdebug is activated.

There is a workaround for this problem. In php.ini configure:

xdebug.start_with_request = trigger

and in your PHP-Code use:

xdebug_break();

As a consequence of this, xdebug will start working only if it receives the signal "xdebug_break();" in your PHP code. There will be a breakpoint in the line after that. Then you can continue with step debugging etc.

As I said: I don't use PhpStorm, but Visual Studio Code as an IDE. In VS Code you need to install the PHP extension pack and then start the VS Code debugger with "Listen for xdebug".

Hopefully this will work with PhpStorm, too.

Jörg
  • 99
  • 2
  • 10