Docker环境下PhpStorm配置Xdebug
概述
Xdebug的安装
使用的docker-compose,在dockerfile中加入
# 安装Xdebug扩展
COPY ./ext/xdebug-2.6.0.tgz /tmp/xdebug.tgz
RUN mkdir -p /tmp/xdebug \
&& tar -xf /tmp/xdebug.tgz -C /tmp/xdebug --strip-components=1 \
&& rm /tmp/xdebug.tgz \
&& docker-php-ext-configure /tmp/xdebug --enable-xdebug \
&& docker-php-ext-install /tmp/xdebug \
&& rm -r /tmp/xdebug
php.ini配置Xdebug
docker.for.mac.host.internal是宿主ip
[xdebug]
xdebug.idekey = "PHPSTROM"
xdebug.remote_enable = On
xdebug.remote_host = docker.for.mac.host.internal
xdebug.remote_port = 9001
xdebug.remote_log = /var/log/xdebug.log
phpstorm配置
-
mac的phptorm2019.3版本如图找到debug设置,填入端口号与php.ini的xdebug.remote_port一致
-
如图进行验证
-
点击phpstorm上方开启监听
-
请求加参数XDEBUG_SESSION_START,如http://127.0.0.1:8090/gql/index?XDEBUG_SESSION_START
-
首次会弹出设置,直接接受。server name和server port和我们访问的不一样也不要改(也改不了)
-
修改server中php项目根目录在远程服务器的物理路径
完成
恭喜断点调试开始了