PhpStorm 未接收 xdebug 连接 : PhpStorm event log : Cannot evaluate expression 'isset($_SERVER[' PHP_IDE_CONFIG'])'

标签 php phpstorm xdebug

我为 PhpStorm 和 xdebug 配置了一切,我正在运行 Ubuntu 14.04。

没有建立回 IDE 的连接,我在 IDE 事件日志中得到了这个

无法接受外部 Xdebug 连接:无法计算表达式 'isset($_SERVER['PHP_IDE_CONFIG'])' – Osama Salama 13 分钟前

我会将我在不同地方配置的配置值放在一起。因为我找不到问题出在哪里

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 信息

调试

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

我还验证了远程调试环境。一切都很好。 https://www.jetbrains.com/phpstorm/help/validating-the-configuration-of-a-debugging-engine.html结果也很好。

最后可能的手段是 xdebug 日志文件:

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. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="4474"><engine version="2.3.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>
<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>
<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>
<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>
<- status -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="4" status="starting" reason="ok"></response>
<- step_into -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="5" status="stopping" reason="ok"></response>
<- eval -i 6 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="6"><error code="5"><message><![CDATA[command is not available]]></message></error></response>
Log closed at 2015-03-13 14:39:01

最佳答案

我在 PhpStorm 中遇到了与 OP 完全相同的错误。

This answer到另一个问题为我解决了问题,但我想在我自己的答案中添加更多细节。

主要问题是 xdebug 加载不当。其他答案中提到的服务器映射问题对我来说不是问题。

如果加载 phpinfo() 页面并找到 xdebug 部分,您会看到:

XDEBUG NOT LOADED AS ZEND EXTENSION

XDEBUG NOT LOADED AS ZEND EXTENSION

然后你必须先解决这个问题,然后再尝试其他任何事情!但有时,如果您有多个 php.ini 文件,这可能需要一些工作来追踪。

同样在您的 phpinfo() 页面中,搜索“php.ini”(它应该就在顶部附近)并查看您的“配置文件 (php.ini) 路径”,以及你的“加载的配置文件”。这些是您的 xdebug 可能正在加载的地方。

enter image description here

在我的例子中,我在/usr/local/lib/php.ini 的主配置文件中正确地将它作为 Zend 扩展加载,如下所示:

zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"

但是在/home/someuser/public_html/php.ini 中的加载配置文件中,我错误地加载了它,如下所示:

extension=xdebug.so

修复该问题后,我又可以使用 PhpStorm 进行远程调试了。

作为旁注,我在 PhpStorm 中看到的第一个错误与 OP 提到的完全相同,它看起来像这样:

PhpStorm xdebug server variables error

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

( 一开始我认为是因为没有正确加载扩展,PhpStorm 无法在服务器上执行 PHP 代码。但现在我认为 PhpStorm 只有在配置了解释器的情况下才能执行 php 代码,这不是必需的用于调试。对于调试,PhpStorm 只需要 xdebug 连接和正确的路径映射。)

后来,我在我的服务器上的 xdebug 日志中发现“命令不可用”错误,这让我找到了解决方案。

顺便说一句,这是我在本地 php.ini 中用于 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"

关于PhpStorm 未接收 xdebug 连接 : PhpStorm event log : Cannot evaluate expression 'isset($_SERVER[' PHP_IDE_CONFIG'])',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29035705/

相关文章:

javascript - 从同一页面加载具有单击功能的 div 并替换为已加载的其他 div

php - 将一段文本编码为其等效的 HTML

phpstorm 中的 CSS3 转换

intellij-idea - PhpStorm中的行距

html - 如何让 Vim HTML 语法突出显示来为整个标签着色?

php - 为什么 PHPUnit 将一些右大括号显示为未被覆盖?

php - 选择比较另一个表中的字段的记录

php - 使用传递值重定向页面

centos - X-debugger 在查看 PHP 服务器端脚本中的变量时显示意外更改

xml - 如何轻松调试布局 Xml 警告/错误?