![](/img/trans.png)
[英]Using Xdebug and PhpStorm with Docker container on Windows
[英]Using xdebug through Docker container in PhpStorm
我已經閱讀了一些關於此的帖子,但在我的案例中沒有任何幫助,或者只是忽略了丟失的部分。
我無法使用Docker容器讓xdebug在PhpStorm上工作。
泊塢窗,compose.yml
version: '2'
services:
web:
image: nginx:latest
volumes:
- .:/usr/share/nginx/html
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/logs/nginx
- ./nginx/site-enabled/default.conf:/etc/nginx/sites-enabled/default.conf
ports:
- "80:80"
depends_on:
- php
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: local_db
MYSQL_USER: root
MYSQL_PASSWORD: 1234
ports:
- "3306:3306"
php:
build: images/php
volumes:
- .:/usr/share/nginx/html
- ./config/docker/php/php.ini:/usr/local/etc/php/php.ini
- ./config/docker/php/ext-xdebug.ini:/usr/local/etc/php/conf.d/ext-xdebug.ini
- ./config/docker/php/php-fpm.conf:/usr/local/etc/php-fpm.conf
user: www-data
depends_on:
- db
配置/搬運工/ PHP / EXT-xdebug.ini
zend_extension="/usr/lib/php7/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.overload_var_dump=1
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.20.0.1 # ip of host inside docker container
xdebug.remote_log=/usr/share/nginx/html/xdebug.log
來自xdebug.log的錯誤
Log opened at 2017-05-31 11:01:14
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.20.0.1:9000.
W: Creating socket for '172.20.0.1:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-05-31 11:01:14
在PhpStorm我正在使用具有以下設置的遠程調試器:
服務器
Host - 127.0.0.1
Port - 80
服務器上的絕對路徑
/usr/share/nginx/html
IDE會話密鑰
PHPSTORM
好的,我在這里得到了解決方案
https://forums.docker.com/t/ip-address-for-xdebug/10460/9
我必須將我的內部ip設置為xdebug.remote_host
並禁用xdebug.remote_connect_back=0
似乎這是一個osx的事情。 希望這能幫到這里的人
我發現ext-xdebug.ini
上的以下配置適用於Docker for Mac
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
Docker自動在容器中定義host.docker.internal
。 所以我們簡單地指出xdebug認為host.docker.internal
是主機的IP(顯然是)。 這樣,我們就不必依賴於在docker容器和主機之間不斷更改內部IP。
更多信息可以在這里找到https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.