3

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
8
  • Sounds like you have some scheduled task (most common reason) written in PHP (called directly by scheduler on as one of the steps) that gets executed in CLi environment (or better say, not running in context of actual web server). PhpStorm needs server name to differentiate between connections (what "PHP | Server" entry to use etc) and in your case (remote CLI in general) it is absent (which is absolutely normal as you need to provide such info manually as per your links). Commented Jan 25, 2016 at 16:20
  • I may only suggest to enable "Ignore external connections through unregistered server configurations" option at Settings/Preferences | Languages & Frameworks | PHP | Debug -- should help. Note that if you need to configure another server config you will either have to do it manually or disable this option if you want help from IDE. Commented Jan 25, 2016 at 16:24
  • 1
    That's exactly what I meant -- your system wide scheduler (cron in your Linux case) Commented Jan 25, 2016 at 16:28
  • 1
    You possible alternatives are: 1) have remote_autostart=0 and use xdebug_break(); in your actual PHP code (programmatic breakpoint) 2) have different PHP installations (or at least different php.ini config files) for you actual code that you developing and system-wide PHP for ordinary tasks (which should not be debugged -- no xdebug no issue (+ code runs around 2x faster)) Commented Jan 25, 2016 at 16:34
  • 1
    I have same problem. It's definitely caused by 09,39 * * * * root [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean from /etc/cron.d/php5. But I have Ignore external connections... checked in my PhpStrom. Commented Mar 3, 2016 at 8:04

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

Comments

5

As others have mentioned, this is caused by the sessionclean script (on my machine, this is located in: /usr/lib/php/sessionclean) which gets called by cron every 30 minutes.

If you want to keep xdebug.remote_autostart=1 on your system while preventing sessionclean to start remote debugging connections, just edit sessionclean (it's a simple shell script) and add -d "xdebug.remote_autostart=0" to its invocation of the php command.

For example, on my system I had to change this line:

session_config=$(PHP_INI_SCAN_DIR=/etc/php/${version}/${conf_dir}/conf.d/ php${version} -c /etc/php/${version}/${conf_dir}/php.ini -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')

into this:

session_config=$(PHP_INI_SCAN_DIR=/etc/php/${version}/${conf_dir}/conf.d/ php${version} -c /etc/php/${version}/${conf_dir}/php.ini -d "xdebug.remote_autostart=0" -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.