2

I am having an error running the tests for my application in PhpStorm using Codeception. My code is running through Vagrant.

In the top line of my index.php for the Codeception test is:

ini_set('xdebug.max_nesting_level', 200);

I installed xdebug through homebrew and that's in my php version output:

PHP 7.1.12 (cli) (built: Dec  2 2017 12:15:25) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans   

When I run the tests though I get an error in PhpStorm event log:

Cannot accept external Xdebug connection: Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'

In my PhpStorm settings I have it set up to accept external connections:

enter image description here

and in php info I have xdebug setting available:

$ php -i | grep xdebug                 
Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
...
xdebug.remote_connect_back => On => On

In the /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini I set xdebug.remote_connect_back=1 based on this thread.

What can I do to remove the Cannot accept external Xdebug connection error and run tests?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Connor Leech
  • 18,052
  • 30
  • 105
  • 150
  • 1
    Hmm, the `$_SERVER['PHP_IDE_CONFIG']` is intended for remote CLI debugging I think . Missing idekey? `xdebug.idekey="PHPSTORM"`. Read this already? https://stackoverflow.com/questions/29035705/phpstorm-is-not-receiving-xdebug-connections-phpstorm-event-log-cannot-evalu Mine works but I have to click little green phone button to "listen", – ficuscr Dec 20 '17 at 19:15
  • setting the idekey did not fix or change the error. I do have the green telephone on listening for debug connections – Connor Leech Dec 20 '17 at 19:47
  • So, with this approach, you are raising a flag in the request to tell the IDE to pick up. Look at the request, how is the variable passed in the request? Think I've used a browser toolbar button to add it in when I want to debug in IDE. – ficuscr Dec 20 '17 at 19:55
  • Here we go: https://confluence.jetbrains.com/display/PhpStorm/Browser+Debugging+Extensions – ficuscr Dec 20 '17 at 19:56

2 Answers2

6

I was able to fix this by changing the remote port to an unused one such as 9898:

[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
xdebug.remote_port = 9898

And then update that in PhpStorm settings:

enter image description here

Connor Leech
  • 18,052
  • 30
  • 105
  • 150
0

In my case, (using Symfony framework and PhpStorm )it was just related to some cache i had to clean! Took me 2 hours to figure out as I have everything configured and properly set but still the Events didn't fire up.

So please clear always the cash whenever you have a clueless issue like this: if it didn't work, then move on t other steps to debug the source of the issue.

numediaweb
  • 16,362
  • 12
  • 74
  • 110