1.利用docker構(gòu)建dnmp環(huán)境,
大家可以參考這個進行構(gòu)建 傳送門
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
重點看這幾個參數(shù)
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環(huán)境
1.進入Langusges&Frameworks>PHP

image.png
2.進入CLI Interpreter選擇PHP

image.png
3. 進入Docker Server選擇進行連接Docker

image.png
務必是Connection successful狀態(tài)
3.2 Debug相關(guān)
1.Debug端口配置

image.png
2.配置Servers

image.png
3.Run -> Edit Configuration 或者 或者點擊 PHPstorm 右上角的 Edit Configuration

image.png
4.開始調(diào)試
開啟Debug模式

image.png
請求項目

image.png
查看Debug信息

image.png
周末在家記錄一下,希望可以幫助到你,成就別人,成就自己