Phpstorm&Docker&Xdebug调试

1.利用docker构建dnmp环境,

大家可以参考这个进行构建 传送门

docker-compose up -d 之前,在php.ini中 Xdebug 配置如下

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
; Set to host.docker.internal on Mac and Windows, otherwise, set to host real ip
xdebug.remote_host = docker.for.mac.localhost
xdebug.remote_port = 9999
xdebug.remote_log = /var/log/php/xdebug.log
xdebug.idekey = phpstorm

2.查看phpinfo

重点看这几个参数
Directive             Local Value               Master Value
xdebug.idekey         phpstorm                  phpstorm
xdebug.remote_port    9999                      9999
xdebug.remote_host    docker.for.mac.localhost  docker.for.mac.localhost
xdebug.remote_log     /var/log/php/xdebug.log   /var/log/php/xdebug.log

3.配置phpstorm

3.1配置PHP环境
1.进入Langusges&Frameworks>PHP
image.png
2.进入CLI Interpreter选择PHP
image.png
3. 进入Docker Server选择进行连接Docker
image.png

务必是Connection successful状态

3.2 Debug相关

1.Debug端口配置
image.png
2.配置Servers
image.png
3.Run -> Edit Configuration 或者 或者点击 PHPstorm 右上角的 Edit Configuration
image.png

4.开始调试

开启Debug模式
image.png
请求项目
image.png
查看Debug信息
image.png

周末在家记录一下,希望可以帮助到你,成就别人,成就自己

你可能感兴趣的:(Phpstorm&Docker&Xdebug调试)