2

I have a local ddev (docker based) PHP Drupal 7 development environment set up. I have set up Behat tests for this site utilizing the Behat Drupal Extension.

All of the Behat context files and the associated composer vendor folder lives outside of the site's web root in a testing folder. The folder structure looks something like:

  • Project

    • testing

    • public_html

I have xdebug enabled and using PhpStorm. I have set up a PhpStorm debug server and provided correct path mappings.

Debugging php code via a browser works great, debugging CLI commands works great. My issue occurs when I try to debug all code while running Behat tests via the CLI.

In the PhpStorm PHP Server configuration if I only set the path mappings for the testing folder I can debug any code within the testing folder and there are no curl issues. I obviously can't debug code in the public_html folder because I have not set the path mappings. When I do set the path mappings for both the testing and public_html folders, I can debug all code but any behat step definition that includes a Mink curl_exec() call to the site's local url, hangs for anywhere from 3 to 10 minutes!

My goal...

To be able to debug all php code in the testing and public_html folders while running Behat tests without curl_exec() hanging.

What I have tried...

I have PhpStorm Debug Max Simultaneous Connections set to 10 and have tried 20.

Here are my xdebug remote config settings:

xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => host.docker.internal => host.docker.internal
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000

All of the following have all resulted in curl hanging:

  • Set xdebug.remote_autostart=0 and started the Xdebug session by passing a XDEBUG_CONFIG=idekey=PHPSTORM environment variable in with my behat command AND
    • NOT passing any cookie or GET parameter with the curl call.
    • Passing the same idekey as a cookie and GET parameter with the curl call
    • Passing a different idekey as a cookie and GET parameter with the curl call

Any help is greatly appreciated!!

LazyOne
  • 158,824
  • 45
  • 388
  • 391
tame4tex
  • 31
  • 3
  • 1
    Collect Xdebug log, it may say what is going on (if it tries to connect and where). `xdebug.remote_log` – LazyOne May 16 '19 at 09:20
  • Is this only happening when you try to access a URL from the same application? – Nico Haase May 16 '19 at 09:25
  • Thank you for the suggestions @LazyOne and NicoHaase. Yes the issue is only happening when a URL from the same application. I collected Xdebug logs and they revealed that the connection was being made and getting stuck on a Run command. This lead me to think it was something PhpStorm specific or the site not responding that was causing the issue. I have detailed more in my answer below. Thanks again! – tame4tex May 17 '19 at 18:33

1 Answers1

1

After following @LazyOne advice I looked at the Xdebug logs more closely and noticed the hanging was occurring after a successful xDebug connection was made. This lead me to two possible causes; some rouge breakpoint that was not getting registered in the PhpStorm Debug tool window or something on the site was delaying the response.

So I did the following:

  1. Removed all PhpStorm Debug breakpoints in the application and restarted PhpStorm.
  2. Realized the Automatic Cron setting in Drupal 7 Configuration was set to run every 1 Day so switched it to Never. My thinking was possibly the execution of Drupal Cron was getting stuck and not completing so every HTTP request was hanging.

It worked and now I wish I had tested each of these steps separately because I don't know which one exactly was the solution. I am leaning towards #1 because when I switched off debugging in PhpStorm the Behat test would execute with no delay. Either way, if you have a similar issue try both of the above.

tame4tex
  • 31
  • 3