簡體   English   中英

phpstorm和docker中的xdebug

[英]xdebug in phpstorm and docker

我設法將xdebug與docker和phpstorm結合使用。 對於http呼叫... IE

http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM

但是,當我嘗試運行phpunit測試時,它無法與phpstorm連接

我在phpstorm中進行了正確的目錄映射,並且還在我的export XDEBUG_CONFIG="idekey=PHPSTORM" -instance export XDEBUG_CONFIG="idekey=PHPSTORM"上運行了以下內容

我也在docker上嘗試過:export PHP_IDE_CONFIG ='serverName = web.docker'並在phpstorm web.docker上命名服務器配置。 仍然可以通過http而不是CLI進行工作

那么我也可以讓phpstorm和xdebug一起為命令行工作嗎?

這是我的文件: /etc/php5/cli/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.17.42.1
dxdebug.remote_autostart=1

當我打開日志記錄並使用xdebug_remote_host IP地址時,我得到了

W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:20:39

Log opened at 2015-10-13 12:22:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 172.17.42.1:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:22:58

Log opened at 2015-10-13 12:23:58
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 192.168.99.100:9000. :-|
E: Could not connect to client. :-(
Log closed at 2015-10-13 12:23:58

解決方案(編輯)通過打開xdebug日志記錄,我看到它成功連接到192.168.99.1因此這解決了問題

xdebug.remote_host=192.168.99.1

我現在想到兩件事:

  1. xdebug.remote_host設置正確嗎? 對於HTTP鏈接,您提供了192.168. 地址,回程是172.17. 地址。 您可以在該IP上ping您的主機嗎?

  2. 在您的ini文件中,其內容為:

     dxdebug.remote_autostart=1 

    這只是這里的錯字,還是實際上在您的配置文件中? 因為它應該讀取xdebug而不在其前面加上“ d”。 它應該是:

     xdebug.remote_autostart=1 

    僅在執行以下腳本時添加選項時才添加d:

     php -dxdebug.remote_autostart=1 script.php 

如果仍然不能解決問題,請通過向配置中添加如下內容來啟用遠程日志:

xdebug.remote_log = /var/log/xdebug_remote.log

也許這將有助於發現問題。

對我有用的是使用此配置的ssh隧道xdebug.remote_connect_back = 0 xdebug.remote_host = 127.0.0.1

請參閱: Mac的Docker上具有SSH隧道的Xdebug

從Docker-17.06開始,您可以通過靜態主機名訪問Container內Mac上托管的服務: docker.for.mac.localhost

完整的答案在這里: https : //stackoverflow.com/a/48495802/1241980

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM