mac使用phpstorm開啟xdebug

oliver-l發表於2020-09-16

使用laravel進行開發,可以通過使用dd,dump等方法進行除錯,但是現在我想通過xdebug一步步除錯,看看框架都做了什麼流程,在此記錄一下如何使用phpstorm開啟xdebug

安裝xdebug擴充套件

一句話搞定安裝擴充套件

pecl install xdebug

新增配置

[xdebug]
zend_extension="xdebug.so"
xdebug.remote_autostart=1
xdebug.default_enable=1
xdebug.remote_port=9001
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM

使用phpinfo()檢視是否安裝完成xdebug擴充套件,若出現以下內容,則說明成功安裝xdebug擴充套件

mac使用phpstorm開啟xdebug

並檢視xdebug.remote_enable,確保為on開啟
mac使用phpstorm開啟xdebug

配置phpstorm

我使用的phpstorm版本為2019.3

點選phpstorm左上角phpstorm>>Preferences

點選Languages & Frameworks > PHP > Debug,這裡配置Debug port與我們配置的xdebug.remote_port對應,這裡配置9001
mac使用phpstorm開啟xdebug

點選Languages & Frameworks > PHP > Debug > DBGp Proxy,配置本地資訊

mac使用phpstorm開啟xdebug

點選Languages & Frameworks > PHP > Servers,這裡配置我們需要除錯的域名,如下按照你的域名去配置即可

mac使用phpstorm開啟xdebug

點選這裡新增配置

mac使用phpstorm開啟xdebug

點選新增PHP Web Page
mac使用phpstorm開啟xdebug

這裡選擇新增之前Servers新增的配置
mac使用phpstorm開啟xdebug

配置完成後,就可以愉快的使用phpstorm進行debug

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章