可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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 event Log
I'll put together configuration values I configured in various places. As I can't find out where is the problem
php.ini
zend_extension = /usr/lib/php5/20121212/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_connect_back = 1 xdebug.remote_autostart = 1 xdebug.remote_log=xxx/xdebug.log xdebug.IDE_key=PHPSTORM
PHP info
xdebug
xdebug support enabled Version 2.3.1 IDE Key PHPSTORM Supported protocols Revision DBGp - Common DeBuGger Protocol $Revision: 1.145 $ Directive Local Value Master Value xdebug.auto_trace Off Off xdebug.cli_color 0 0 xdebug.collect_assignments Off Off xdebug.collect_includes On On xdebug.collect_params 0 0 xdebug.collect_return Off Off xdebug.collect_vars Off Off xdebug.coverage_enable On On xdebug.default_enable On On xdebug.dump.COOKIE no value no value xdebug.dump.ENV no value no value xdebug.dump.FILES no value no value xdebug.dump.GET no value no value xdebug.dump.POST no value no value xdebug.dump.REQUEST no value no value xdebug.dump.SERVER no value no value xdebug.dump.SESSION no value no value xdebug.dump_globals On On xdebug.dump_once On On xdebug.dump_undefined Off Off xdebug.extended_info On On xdebug.file_link_format no value no value xdebug.force_display_errors Off Off xdebug.force_error_reporting 0 0 xdebug.halt_level 0 0 xdebug.idekey no value no value xdebug.max_nesting_level 256 256 xdebug.max_stack_frames -1 -1 xdebug.overload_var_dump On On xdebug.profiler_aggregate Off Off xdebug.profiler_append Off Off xdebug.profiler_enable Off Off xdebug.profiler_enable_trigger Off Off xdebug.profiler_enable_trigger_value no value no value xdebug.profiler_output_dir /tmp /tmp xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p xdebug.remote_autostart On On xdebug.remote_connect_back On On xdebug.remote_cookie_expire_time 3600 3600 xdebug.remote_enable On On xdebug.remote_handler dbgp dbgp xdebug.remote_host 127.0.0.1 127.0.0.1 xdebug.remote_log /home/nautilus/Desktop/xdebug.log /home/nautilus/Desktop/xdebug.log xdebug.remote_mode req req xdebug.remote_port 9000 9000 xdebug.scream Off Off xdebug.show_exception_trace Off Off xdebug.show_local_vars Off Off xdebug.show_mem_delta Off Off xdebug.trace_enable_trigger Off Off xdebug.trace_enable_trigger_value no value no value xdebug.trace_format 0 0 xdebug.trace_options 0 0 xdebug.trace_output_dir /tmp /tmp xdebug.trace_output_name trace.%c trace.%c xdebug.var_display_max_children 128 128 xdebug.var_display_max_data 512 512 xdebug.var_display_max_depth 3 3
I also validated the remote debugging env. it's all good. https://www.jetbrains.com/phpstorm/help/validating-the-configuration-of-a-debugging-engine.html which also came out fine.
The last possible resort is the xdebug log file:
Log opened at 2015-03-13 14:39:01 I: Checking remote connect back address. W: Remote address not found, connecting to configured address/port: 127.0.0.1:9000. :-| I: Connected to client. :-) -> Log closed at 2015-03-13 14:39:01
回答1:
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
回答2:
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.
回答3:
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
).
回答4:
I had this problem as well and tried every trick I could find, but nothing worked. For me, debugging works most of the time, but sometimes it just stops working with the message: "Cannot accept external Xdebug connection: Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'"
So I eventually realized I had a compilation error in my code (misspelled method name - PhpStorm does not always report these things, at least in my setup). As soon as I corrected the error debugging started working again. Maybe this can help someone struggling.
Although I still have issues with breakpoints not being hit, I can throw in a "xdebug_break();" line in the code and debugging becomes more reliable. The downside with using xdebug_break instead of breakpoints is (apart from the fact that it's more work than just adding a breakpoint) the local variables not being displayed in the PhpStorm debugger for some reason (only globals are shown). That makes debugging less convenient, but at least I can make it work.
Apparently you can't have everything :) Coming from the Java world, good debugging is just something I have been able to take for granted, but I have now realized how spoiled I have been :)
回答5:
test.phpcan leadCannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])
'
Use another name for file.
回答6:
Another thing is to make sure that you disable any firewall you have and which might block remote connections.