I had the exact same error in PhpStorm as the OP.
This answer to a different question solved the problem for me, but I would like to add more detail in my own answer.
The main issue was improperly loaded xdebug. The server mapping issues mentioned in other answers was not an issue for me.
If you load your phpinfo()
page and find the xdebug section, and you see this:
XDEBUG NOT LOADED AS ZEND EXTENSION
Then you have to fix that before you try anything else! But sometimes this can take some work to track down, if you have multiple php.ini
files.
Also in your phpinfo()
page, search for "php.ini", (it should be right near the top) and see your "Configuration File (php.ini) Path", and your "Loaded Configuration File". Those are where your xdebug may be loading.
In my case, I correctly loaded it as a Zend extension in my main configuration file in /usr/local/lib/php.ini, like so:
zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
But in my Loaded Configuration file in /home/someuser/public_html/php.ini, I had it incorrectly loaded like this:
extension=xdebug.so
After fixing that, remote debugging with PhpStorm is working again for me.
As a side note, the first error I saw in PhpStorm was the exact same one the OP mentions, and here is what it looks like:
Cannot accept external Xdebug connection
Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'
( At first I thought that, because the extension was not loaded properly, PhpStorm was not able to execute PHP code on the server. But now I think PhpStorm only executes php code if you configured an interpreter, which isn't necessary for debugging. For debugging, PhpStorm just needs the xdebug connection and the correct path mappings.)
Later, I found the "Command is not available" error in the xdebug log on my server, which led me to the solution.
Here, by the way, is what I have in my local php.ini
for xdebug:
;extension=xdebug.so <- this is the bad line commented!
zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_port="9000"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp/xdebug-someuser/"
xdebug.profile_enable_trigger=1
xdebug.trace_enable_trigger=1
xdebug.idekey="PHPSTORM"
xdebug.remote_log="var/log/xdebug/xlog"