Connor Leech
Connor Leech

Reputation: 18873

PhpStorm - Cannot accept external Xdebug connection

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?

Upvotes: 2

Views: 4208

Answers (2)

numediaweb
numediaweb

Reputation: 17030

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.

Upvotes: 0

Connor Leech
Connor Leech

Reputation: 18873

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

Upvotes: 6

Related Questions