Search code examples
debuggingphpstormxdebug

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


I'm using the PHPstorm as my main PHP development enviroment and XDebug to debugging my applications.

My only problem is the message "Cannot accept external Xdebug connection: Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'" appearing from time to time.

I already saw some solutions to the problem here and also in the JetBrains support (here and here), but my problem is a little bit different 'cause I CAN Debug normally, but the message continues to appear.

See the print of the event log below. Apparently, the message appears every 30 minutes.

event log of phpstorm

FYI, I'm debbuging a webservice, so, I configure the Xdebug to listen all HTTP requests, I click the "Start Listen PHP Debug Connections button" (green in the figure) and then launch the requests through Advannced Rest Client(Chrome).

As I said, I can debug without problems, so I just want to understand the message. Can it cause any problem? Am I doing something wrong? Can I disable this message? How?

I tried the solutions in the linked question, but the message still there.

This is my Xdebug configuration:

[Zend]
zend_extension="/usr/lib/php5/20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=0

Solution

  • Your description (repetitive task) + screenshot (happens every 30 minutes exactly) suggests that you have some task gets executed by some schedule (system wide scheduler -- cron in your Linux case) and it is written in PHP (either PHP script gets called directly by scheduler or as one of the steps in main task).

    Such task gets executed in CLI environment (or, better wording for your case, not running in context of actual web server). When PhpStorm receives incoming debug request (that was initiated outside of IDE) it needs some info to identify what settings to use (which of PHP | Servers entries to use). Such info usually (majority of cases) already present when PHP gets executed in web server context and it's absent when executed in terminal (CLI) so that you have to provide it manually.

    The easiest solution would be to enable Ignore external connections through unregistered server configurations option at Settings/Preferences | Languages & Frameworks | PHP | Debug. Note though that if you need to configure another server config (which happens rather rarely for majority of projects) you will either have to do it manually or disable this option if you want some help from IDE.


    Cronjob is the actual reason for repetitiveness. Another issue here is the fact that xdebug actually tries to debug it. Ideally it should not be happening at all and you better configure your environment in such way that normal tasks use normal PHP installation (with no xdebug) and dev environment uses either separate PHP installation or at very least uses separate php.ini config. Just having xdebug enabled already makes script running 2x or so slower and, for example, composer will notify you if it detects xdebug enabled.

    You have xdebug.remote_autostart=1. With this xdebug attempts to debug every single PHP script that it executes. I understand that you have enabled this to simplify your dev life (as sometimes it's hard and inconvenient to pass xdebuger "debug this now" flag in other way (e.g. cookie or GET/POST param)) but as you can see it's causing some inconveniences.

    One of the possible options here (in addition to aforementioned separate configs) is to have xdebug.remote_autostart=0 and use xdebug_break(); in your actual PHP code (programmatic breakpoint). But this may be inconvenient for other reasons -- the need to modify script source code to enable/disable debugging.