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

2.进入CLI Interpreter选择PHP

3. 进入Docker Server选择进行连接Docker

务必是Connection successful状态
3.2 Debug相关
1.Debug端口配置

2.配置Servers

3.Run -> Edit Configuration 或者 或者点击 PHPstorm 右上角的 Edit Configuration

4.开始调试
开启Debug模式

请求项目

查看Debug信息

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