[英]Can't get Xdebug to work in PHPStorm with PHP & XAMPP on Mac OS
[英]Can't get Xdebug to work (mac+PhpStorm+Laradock+Xdebug)
我需要在我的本地環境中調試代碼。准確的說,是我mac中的一個Laradock。 但是我試了很多次都失敗了。
Mac version MoJave 10.14.2
Docker version 18.09.0, build 4d60db4
Docker-compose version 1.23.2, build 1110ad01
Laradock version(commit id) a03c225e279910b9393b5e95fbffe5081b9e5a95
PhpStorm version 2018.1.1 Build #PS-181.4445.72
X調試狀態:
PHP 7.2.15 (cli) (built: Feb 21 2019 23:48:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.15, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
信息:
工作區/xdebug.ini:
php-fpm/xdebug.ini:
docker-composer ps:
PhpStorm 中的 Xdebug 設置:
PhpStorm 中的服務設置:
PhpStorm 中的遠程調試設置:
PhpStorm 中的 PHP 網頁設置:
以上都是我的配置信息。
我們來看看端口信息
➜ laradock git:(master) lsof -i:9001
開始監聽 PHP 調試連接
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
當我輸入 URL 並按下 Enter 鍵時,窗口將跳轉到 PhpStorm
PhpStorm 是這樣的:
當我點擊'Step Over(F8)'時,PhpStorm 是這樣的:
調試無法進行,Chrome 處於等待狀態:
端口信息:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
phpstorm 268 lightWay 71u IPv4 0xa71f266f59f45e2d 0t0 TCP localhost:etlservicemgr->localhost:51955 (CLOSE_WAIT)
phpstorm 268 lightWay 73u IPv4 0xa71f266f669227ad 0t0 TCP localhost:etlservicemgr->localhost:55017 (ESTABLISHED)
com.docke 648 lightWay 30u IPv4 0xa71f266f592027ad 0t0 TCP localhost:55017->localhost:etlservicemgr (ESTABLISHED)
如果我結束我的瀏覽器訪問,我得到:
端口信息:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
phpstorm 268 lightWay 71u IPv4 0xa71f266f59f45e2d 0t0 TCP localhost:etlservicemgr->localhost:51955 (CLOSE_WAIT)
phpstorm 268 lightWay 73u IPv4 0xa71f266f669227ad 0t0 TCP localhost:etlservicemgr->localhost:55017 (ESTABLISHED)
com.docke 648 lightWay 30u IPv4 0xa71f266f592027ad 0t0 TCP localhost:55017->localhost:etlservicemgr (ESTABLISHED)
沒有任何變化,Xdebug 連接也沒有中斷。
但如果我點擊“停止 index.php (F12)”,我的瀏覽器請求就會結束。
像這樣的端口:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 17u IPv4 0xa71f266f68032e2d 0t0 TCP *:etlservicemgr (LISTEN)
感覺PhpStorm沒有收到瀏覽器或者Xdebug的請求。
我如何讓 Xdebug 工作?
哦,是的,有時我可以從 PhpStorm 得到提示
但是我已經在./laradock/.env
文件中配置好了。
任何幫助將不勝感激......如果我需要提供更多信息,我會很樂意這樣做。
我的設置未使用 PHPStorm,但嘗試更改以下設置以匹配:
在workspace/xdebug.ini 中設置:
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000
在php-fpm/xdebug.ini 中設置:
xdebug.remote_host=host.docker.internal
請務必重建您的 docker 容器(包括 php-fpm)以包含任何配置更改——這對我來說是缺少的關鍵:
docker-compose down
docker-compose build mysql nginx php-fpm
docker-compose up -d mysql nginx php-fpm
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.