我正在尝试通过 PhpStorm (v2022.3.2) 使用 Xdebug (v3) 从 Docker 容器内部调试 PHPUnit 测试方法。
Xdebug 已正确设置,PhpStorm 中的服务器也是如此。
事实上,如果我从命令行运行测试,Xdebug 将在断点处停止:
XDEBUG_SESSION=1 PHP_IDE_CONFIG="serverName=myapp.localhost" vendor/bin/phpunit --testdox --filter testProfileUpdate
Run Code Online (Sandbox Code Playgroud)
如果我单击测试方法左侧的“bug”图标来调试测试,则会收到以下错误:
未建立连接。可能“xdebug.remote_host=host.docker.internal”不正确。更改“xdebug.remote_host”。
查看PhpStorm 执行的调试测试方法的命令,我看到的是:
[docker://myapp:latest/]:php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host=host.docker.internal /opt/project/vendor/phpunit/phpunit/phpunit --configuration /opt/project/phpunit.xml --filter "/(ProfileTest::testProfileUpdate)( .*)?$/" --test-suffix ProfileTest.php /opt/project/tests --teamcity
Run Code Online (Sandbox Code Playgroud)
我还尝试配置另外两个标志:
-dxdebug.idekey="serverName=myapp.localhost"-dxdebug.session=1结果命令是这样的:
[docker://myapp:latest/]:php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host=host.docker.internal -dxdebug.idekey="serverName=myapp.localhost" -dxdebug.session=1 /opt/project/vendor/phpunit/phpunit/phpunit --configuration /opt/project/phpunit.xml --filter "/(ProfileTest::testProfileUpdate)( .*)?$/" --test-suffix ProfileTest.php /opt/project/tests --teamcity
Run Code Online (Sandbox Code Playgroud)
同样使用此配置,Xdebug 不会启动并且断点将被忽略(并且会弹出错误消息)。
我尝试禁用 PhpStorm 自动传递的参数,转到“设置”>“PHP”>“调试”。
然后,在“高级设置”部分中,我取消标记了“通过命令行传递所需的配置选项”选项。
现在,生成的命令是这样的:
[docker://myapp:latest/]:php /opt/project/vendor/phpunit/phpunit/phpunit --configuration /opt/project/phpunit.xml --filter …Run Code Online (Sandbox Code Playgroud) Visual Studio Code 只允许我在文件上放置 Xdebug 断点.php,但不允许在.module文件上放置 Xdebug 断点。
我需要更改一些配置吗?谢谢。
我正在使用twitter-async库对Twitter进行一些oauth调用,但最终,大量内存正在被耗尽.我尝试运行xdebug执行跟踪,这是我觉得内存泄漏的地方.
json_decode()正在使用47077232字节.好的.这可以.
但是gettype()?为什么这也应该使用相似数量的内存?
怎么可以防止这种情况?
脚本循环运行,内存使用量不断增加.我gc_collect_cycles()在很多地方使用它并且它正在显示出改进.但是这个,我无法理解为什么会发生这种情况.
724.1772 47077232 +2118720 -> json_decode() /var/www/html/includes/classes/twitter/EpiTwitter.php:230
724.1926 49157104 +2079872 -> gettype() /var/www/html/includes/classes/twitter/EpiTwitter.php:232
724.1927 49157104 +0 -> property_exists() /var/www/html/includes/classes/twitter/EpiTwitter.php:240
724.1927 49153520 -3584 -> EpiTwitterJson->__destruct() /var/www/html/includes/classes/twitter/EpiTwitter.php:0
724.1949 46714808 -2438712 -> in_array() /var/www/html/cron.php:156
Run Code Online (Sandbox Code Playgroud) 我尝试在xampp运行时安装xdebug php 5.4.4,花了几个小时后,我仍然无法安装它!
这是我在php.ini中的设置
zend_extension = "Z:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9-x86_64.dll"
xdebug.remote_mode = "req"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="Z:\xampp\tmp"
Run Code Online (Sandbox Code Playgroud)
谁能发现任何错误?
谢谢
我正在重建我的开发环境 - 没有取消wamp或xampp等,并尝试一次安装每个位.到目前为止,这变得令人头痛.我现在安装了Php,apache和mysql,现在想安装xdebug.
我已经去了xdebug网站上的向导并复制并粘贴了我的phpinfo.它工作,但没有建议我安装哪个版本,所以我一直在尝试不同的,看看哪个将工作 - 没有喜悦.
在apache错误日志中指出
Failed loading c:\wamp\php\ext\php_xdebug-2.2.0-5.4-vc9.dll
Run Code Online (Sandbox Code Playgroud)
在我的php.ini中,我有以下xdebug条目:
zend_extension = "c:\wamp\php\ext\php_xdebug-2.2.0-5.4-vc9.dll"
[xdebug]
xdebug.remote_enable = true
xdebug.profiler_enable = true
xdebug.profiler_enable_trigger = true
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.auto_trace=1
xdebug.trace_format=1
xdebug.profiler_append=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_output_dir="c:/wamp/tmp"
xdebug.trace_output_name= %t.trace
Run Code Online (Sandbox Code Playgroud)
我的php是5.4.3 x64我的apache是2.4.4 x64操作系统:Win 7 64bit
我试过xdebug版本:
php_xdebug-2.2.0-5.4-vc9.dll
php_xdebug-2.2.2-5.4-vc9-nts.dll
php_xdebug-2.2.2-5.5-vc11-x86_64.dll
Run Code Online (Sandbox Code Playgroud)
我假设它是一个兼容性选项,但由于向导类型失败,我不确定具有哪个版本.
我怎样才能使这个工作,并确保哪个是正确的版本
谢谢
我通过puphpet.com生成一个vagrantbox(Ubuntu Trusty 14.04,nginx,php5.5,mysql,redis,(..)) - 这很好用.
在我的Mac上我只需要切换这个小图标,如下图所示在phpstorm中.没有别的,我可以直接开始设置我的断点,它的工作原理.VM或phpstorm中没有进一步的xdebug设置.

我的问题是,我无法在流浪的windows(7)环境中进行设置.我用谷歌搜索并尝试了几个教程 - 但它仍然无法正常工作.
Windows环境的任何tipps?这是我的puphpet config.yaml https://gist.github.com/wiesson/2fb2e8ebfef7f8d4e800
这可能与防火墙有关吗?
我的系统是
我安装了xdebug dll,就像在https://xdebug.org/docs/install中提到的那样.
php.ini中:
[xdebug]
zend_extension=F:\wamp64\bin\php\php5.6.25\ext\php_xdebug-2.5.0-5.6-vc11-x86_64.dll
Run Code Online (Sandbox Code Playgroud)
我查看了php.ini,发现了zend-Logo和这个
编译器MSVC11(Visual C++ 2012)
...
该程序使用Zend脚本语言引擎:
Zend Engine v2.6.0,版权所有(c)1998-2016 Zend Technologies
with Xdebug v2.5.0,Copyright(c)2002-2016,由Derick Rethans提供
我在https://xdebug.org/wizard.php上运行测试并得到了
Summary
Xdebug installed: no
Server API: Command Line Interface
Windows: yes - Compiler: MS VC11 - Architecture: x64
Zend Server: no
PHP Version: 5.6.25
Zend API nr: 220131226
PHP API nr: 20131226
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\WINDOWS
Configuration File: …Run Code Online (Sandbox Code Playgroud)我的开发环境是: - MacOs High Sierra - PhpStorm - PHP 5.6 - Apache 2.4 - Xdebug 2.5.5
xdebug的php配置文件:
[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_mode=jit
xdebug.remote_autostart=1
xdebug.remote_handler = dbgp
xdebug.force_display_errors=1
xdebug.idekey="PHPSTORM"
xdebug.remote_enable=1
xdebug.show_error_trace=1
xdebug.remote_log="/Users/user/www/xdebug_remote.log"
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/Users/user/www/xdebug_profiler"
Run Code Online (Sandbox Code Playgroud)
在PHPStorm调试验证工具中,似乎所有内容都已启动并运行:
xdebug调试日志是
log opened at 2018-03-21 12:56:51
I: 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="file:///Users/users/www/slt/index.php" language="PHP"
xdebug:language_version="5.6.33" protocol_version="1.0" appid="2764"
idekey="PHPSTORM"><engine version="2.5.5"><![CDATA[Xdebug]]></engine><author>
<![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url>
<copyright><![CDATA[Copyright (c) 2002-2017 by Derick Rethans]]></copyright>
</init>
-> <response xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok">
</response>
Log …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用VScode设置Xdebug,但是每当设置断点时,它都会忽略它。
我安装了https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug并按照说明进行操作(Windows),我还使用了Xdebug向导,这是我的配置:
VSCode-launch.json
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
Run Code Online (Sandbox Code Playgroud)
php.ini
zend_extension = D:\wamp\bin\php\php7.1.16\ext\php_xdebug-2.6.1-7.1-vc14.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_log=D:\wamp\logs\xdebug.log
Run Code Online (Sandbox Code Playgroud)
注意:我找不到任何日志,我可能没有设置正确性,但是我也不知道如何使其正常工作
的PHP -V
$ php -v
PHP 7.1.16 (cli) (built: Mar 28 2018 21:27:36) ( ZTS MSVC14 (Visual C++ 2015) x8
6 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, …Run Code Online (Sandbox Code Playgroud) 在我的任何PhpStorm项目中,调试都不再起作用,当我开始侦听传入的连接时,脚本将被阻塞,直到我停止侦听连接,即使我的代码上没有断点也是如此。当我在第一行上放置一个断点(在其他行上不起作用)时,脚本确实停止了,但是当我告诉他转到下一行时,它再次阻塞了(即使使用了最简单的代码)。
我试图检查调试配置,一切正常(我使用了PhpStorm的验证器),路径映射也正常,上周一切正常,我什么都没改变...
这是我在php.ini上的配置:
xdebug.remote_autostart=1
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_log=[path]/xdebug.log
xdebug.idekey=PHPSTORM
Run Code Online (Sandbox Code Playgroud)
这是我的xdebug.log的一部分,当我在第一行上放置断点然后执行以下操作时:
[4605] Log opened at 2019-03-12 14:13:50
[4605] I: Connecting to configured address/port: 127.0.0.1:9000.
[4605] I: Connected to client. :-)
[...]
[4605] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="19" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" [...] </property></response>
[...]
[4605] <- step_over -i 21
[4605] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_over" transaction_id="21" status="break" reason="ok"><xdebug:message filename="file:///[path]" lineno="4"></xdebug:message></response>
[4605]
Run Code Online (Sandbox Code Playgroud)
第一个响应是当它在第一行的断点处停止时,我已使用“ $ _COOKIE”记录了变量,一切正常,然后执行了一步,脚本就像卡住了。而且问题不可能出在代码中,我尝试了只有2个“ echo”的脚本。我尝试重新启动apache,尝试重新启动PhpStorm,然后尝试重新启动计算机,但没有做任何更改。
我的PhpStorm版本:
PhpStorm 2018.1
Build #PS-181.4203.565, built on March 28, 2018
JRE: 1.8.0_152-release-1136-b20 amd64 …Run Code Online (Sandbox Code Playgroud) xdebug ×10
php ×7
phpstorm ×4
apache ×1
breakpoints ×1
docker ×1
installation ×1
phpunit ×1
puphpet ×1
twitter ×1
vagrant ×1
wamp ×1
wampserver ×1
xampp ×1
xdebug-3 ×1