一、环境
phpstorm版本:2020.03
php版本 :7.1
docker版本:19.03.2
二、给docker安装xdebug
1、安装步骤在这里忽略
三、配置docker中的php.ini
方法一:
直接编辑配置文件
1、进入容器
docker exec -it docker-phpfpm bash
cd /usr/local/etc/php/conf.d/
vim docker-php-ext-xdebug.ini
添加如下内容:
xdebug.remote_enable = 1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.idekey="PHPSTORM"
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
方法二:
将配置文件直接复制到docker中
docker cp /conf.d/docker-php-ext-xdebug.ini eda4b6cf5a14:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
docker cp 本机文件地址 容器ID:容器地址
四、重启容器
docker restart docker-phpfpm
五、配置phpstorm
1、配置php的环境
phpstorm -> Preferences -> PHP



2、配置debug
phpstorm -> Preferences -> PHP -> Debug

3、配置Servers
phpstorm -> Preferences -> PHP -> Servers

4、添加配置
点击 PHPstorm 右上角的 Edit Configuration


5、进行调试
检查是否开启监听()


结束!
网友评论