一、環(huán)境
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??
添加如下內(nèi)容:
????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
方法二:
將配置文件直接復(fù)制到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的環(huán)境
phpstorm -> Preferences -> PHP?



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

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

4、添加配置
點擊 PHPstorm 右上角的 Edit Configuration


5、進行調(diào)試
檢查是否開啟監(jiān)聽()


結(jié)束!