天天看点

php strom怎么调试,如何使用PhpStorm调试docker容器

无法使用以下配置调试Web应用程序:

Dockerfile:

FROM php:7-fpm

RUN yes | pecl install xdebug \

&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \

&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \

&& echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/xdebug.ini \

&& echo "xdebug.remote_host=site.dev" >> /usr/local/etc/php/conf.d/xdebug.ini \

&& echo "xdebug.remote_log=/var/www/site/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini

WORKDIR /var/www/site

nginx服务器(site.conf):

server {

server_name site.dev www.site.dev;

root /var/www/site/src/UI/Web/Silex/Public;

...

}

泊坞窗,compose.yml:

version: '2'

services:

php:

container_name: acme_php

build: etc/docker/development/php

volumes:

- ./:/var/www/site

nginx:

container_name: acme_nginx

build: etc/docker/development/nginx

ports:

- "80:80"

volumes:

- ./:/var/www/site

- ./etc/docker/development/nginx/site.conf:/etc/nginx/conf.d/site.conf

links:

- php

运行服务器:

docker-compose up -d --build

服务器:

php strom怎么调试,如何使用PhpStorm调试docker容器

调试:

php strom怎么调试,如何使用PhpStorm调试docker容器

运行/调试配置:

php strom怎么调试,如何使用PhpStorm调试docker容器

按bug按钮打开chrome但不会在断点处停止:

php strom怎么调试,如何使用PhpStorm调试docker容器

运行phpinfo()看起来像(xdebug区域):

php strom怎么调试,如何使用PhpStorm调试docker容器

xdebug.log:

I: Connecting to configured address/port: site.dev:9000.

I: Connected to client. :-)

->

->

->

为什么不在断点处停下来?

标签:php,docker,phpstorm,xdebug

来源: https://codeday.me/bug/20190705/1391467.html