热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在运行xdebug时,PHPUnit会冻结-PHPUnitFreezeswhenrunwithxdebugactiveandlistening

Imstrugglingsinceyesterdaywithatotallyweirdproblemwhichoccursoutofthenowhere.Imwork

Im struggling since yesterday with a totally weird problem which occurs out of the nowhere. I'm working with PHPStorm in a Symfony Project. PHPUnit Tests are running as usual. If i activate the listening mode in the IDE for debugger connections and run the tests phpunit freezes and the IDE stops automatically after 30seconds. I think it has nothing to do with the ide. If i use MacGDBp i'm experiencing the same. I've checked all Firewall related stuff on my OSX 10.11 and installed php in a new Brew environment. PHP is Version 5.6 from the local OSX and from Brew.

我从昨天起就一直在为一个莫名其妙的问题而烦恼。我正在和PHPStorm合作一个共生项目。PHPUnit测试照常运行。如果我在IDE中为调试器连接激活监听模式并运行测试phpunit,那么IDE将在30秒后自动停止。我认为这和ide没有关系。如果我使用MacGDBp,我也会有同样的体验。我检查了我的OSX 10.11上所有防火墙相关的东西,并在新的Brew环境中安装了php。PHP版本5.6来自本地OSX和Brew。

I'm fairly blind without an debugger :-o

没有调试器,我是相当盲目的:-o

3 个解决方案

#1


0  

Make sure you don't already have another debug session running in the background.

确保您没有在后台运行另一个调试会话。

#2


0  

Xdebug can only listen to one running PHP process at a time. There are usually two possibilities for this.

Xdebug一次只能监听一个正在运行的PHP进程。通常有两种可能。

1) As @adrianGW says, there could be another process already attached to the debugger.

1)正如@adrianGW所说,调试器可能已经附加了另一个进程。

2) Your program tries to load another PHP process and that process can't start until xdebug releases the current thread. This is common that PHPunit will run tests in their own threads so they don't mess up each others envs. Or your are making an http request in your application to a php script on the same server, and that second request is waiting for the first to finish so you are locked until the first script times ou

2)程序试图加载另一个PHP进程,直到xdebug释放当前线程为止,该进程才能启动。PHPunit通常会在自己的线程中运行测试,这样它们就不会互相搞砸env。或者,您在应用程序中向同一个服务器上的php脚本发出一个http请求,第二个请求等待第一个完成,所以您被锁定到第一个脚本时间ou。

There are two fixes in PHPstorm:

PHPstorm有两个补丁:

1) You can change Max Simultaneous Conections to a number greater than 1

1)您可以将最大同时接收次数更改为大于1

2) You can enable Ignore external connections through unregistered servers configurations, but this will only work if the reason for the additional threads is something like a request to another domain on the same server, which xdebug can differentiate as an unregistered server.

2)可以通过未注册的服务器配置启用忽略外部连接,但只有当附加线程的原因类似于对同一服务器上的另一个域的请求(xdebug可以将其区别为未注册的服务器)时,这才会有效。

#3


0  

For me, the cause was @runTestsInSeparateProcesses.

对我来说,原因是@ runtestsinseparation ateprocess。

Here was the symptom: when I turn on debugging in Netbeans and then run export XDEBUG_COnFIG="idekey=netbeans-xdebug remote_connect_back=0 remote_host=10.0.2.2" and then phpunit tests/Unit/MarkAsScheduledUnitTest.php --filter=testHandleExceptionWithMocking, it just outputs "PHPUnit 7.1.2 by Sebastian Bergmann and contributors." and a blinking cursors and hangs there. When I go into Netbeans and quit the debugging, the phpunit test then runs.

症状如下:当我在Netbeans中打开调试,然后运行export XDEBUG_COnFIG="idekey= " Netbeans -xdebug remote_connect_back=0 remote_host=10.0.2.2",然后phpunit test /Unit/MarkAsScheduledUnitTest。php -filter= testhandleexceptionwithmock,它只输出“由Sebastian Bergmann和贡献者编写的PHPUnit 7.1.2”和一个闪烁的游标并挂在那里。当我进入Netbeans并停止调试时,phpunit测试就会运行。

The solution was so temporarily remove @runTestsInSeparateProcesses any time I'm running just that one test or class of tests (rather than the whole suite of tests).

解决方案是在我运行一个测试或测试类(而不是整个测试套件)时临时删除@ runtestsinseparation ateprocess。

https://stackoverflow.com/a/37464247/470749 explains why I'm using @runTestsInSeparateProcesses at all.

https://stackoverflow.com/a/37464247/470749解释了我为什么使用@ runtestsinsecateprocess。

Xdebug breakpoints always work except when using @runTestsInSeparateProcesses? is giving me ideas for how to more easily run a single test without temporarily removing @runTestsInSeparateProcesses.

除了使用@ runtestsinseparation ateprocess之外,Xdebug断点始终有效吗?是关于如何在不临时删除@ runtestsinseparation ateprocess的情况下更容易地运行单个测试的想法。


推荐阅读
author-avatar
索马里7_244
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有