在PhpStorm中通过Docker容器使用xdebug

我已经阅读了一些关于这个post,但没有在我的情况帮助或简单地忽略了失踪的一块。

我不能让xdebug使用Docker容器在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 

configuration/搬运工/ 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中,我正在使用以下设置的远程debugging器:

服务器

 Host - 127.0.0.1 Port - 80 

服务器上的绝对path

 /usr/share/nginx/html 

IDE会话密钥

 PHPSTORM 

好的,我在这里得到了解决scheme

https://forums.docker.com/t/ip-address-for-xdebug/10460/9

我必须将我的内部IP设置为xdebug.remote_host并禁用xdebug.remote_connect_back=0

看来这是一个osx的事情。 希望这有助于这里的人