PhpStorm is not receiving xdebug connections : PhpStorm event log : Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'

后端 未结 7 1167
时光说笑
时光说笑 2020-12-09 02:28

I configured everything for PhpStorm and xdebug to work, I\'m running Ubuntu 14.04.

the connection back to the IDE is not established, and I get this in the IDE eve

相关标签:
7条回答
  • 2020-12-09 02:50

    I have recently had the same problem attempting to debug using PHPStorm under nginx and php-fpm, in my case this was not related to the xdebug, nginx or php-fpm config, it was the path mappings in phpstorm that were missing.

    Initially PHPStorm will notify you when it cannot map a file on the server to a local source file however if it has a mapping to the first files hit ( normally index.php or some such ) but it cannot map a file used at a later stage ( in my case this was the autoloader in the vendor directory of a project using composer ) then PHPStorm will not be able to debug any further and debugging will stop.

    In order to rectify this in PHPStorm go to settings/Languages & Frameworks/PHP/Servers and ensure the root of your project is mapped correctly to it's counterpart directory on the server.

    PHPStorm should then be able to map all the files in your project and debugging should continue.

    I hope this helps.

    0 讨论(0)
  • 2020-12-09 02:50

    Also same error if you missed to set environment variable in docker-compose.yml for your workspace configuration:

    workspace: build: environment: - PHP_IDE_CONFIG=${PHP_IDE_CONFIG}

    0 讨论(0)
  • 2020-12-09 02:59

    Debugging a file named «test.php» in IntelliJ IDEA / PhpStorm can lead to the «Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'» failure.
    Use another name for file.

    0 讨论(0)
  • 2020-12-09 03:07

    Another thing is to make sure that you disable any firewall you have and which might block remote connections.

    0 讨论(0)
  • 2020-12-09 03:08

    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"
    
    0 讨论(0)
  • 2020-12-09 03:10

    For anyone else coming to this issue, there is another potential configuration option that you could be missing.

    Make sure that you have correctly configured your server to use the correct path mapping between your local and remote files.

    For example, if your site root is mounted locally at /home/foo/www/mysite but installed on the server at /www/mysite then you will need to edit your server configuration in PHPStorm to use path mappings (simply enter /www/mysite in the box alongside /home/foo/www/mysite).

    0 讨论(0)
提交回复
热议问题