安裝XDebug
- 使用brew install安裝對(duì)應(yīng)版本的XDebug冀自。使用命令:
brew search xdebug
- 對(duì)于我的mac來(lái)說(shuō),要安裝的版本是php7.1的XDebug幅聘,故而安裝:
brew install homebrew/php/php71-xdebug
- 安裝完畢后執(zhí)行
php -i | grep xdebug
查看是否有輸出(有輸出就是安裝上了)
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
...```
#配置XDebug
* 執(zhí)行`php -i | grep php.ini`找到mac上php.ini的位置
Configuration File (php.ini) Path => /usr/local/etc/php/7.1
Loaded Configuration File => /usr/local/etc/php/7.1/php.ini```
- 使用編輯器打開(kāi)php.ini后凡纳,加入如下配置:
[Xdebug]
zend_extension="/usr/local/Cellar/php71-xdebug/2.5.1/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.idekey = PHPSTORM
注:上面的zend_extension是你的xdebug的真實(shí)安裝位置,如果忘記的話帝蒿,可以執(zhí)行brew info <第一步安裝的xdebug>
來(lái)找到位置
配置PhpStorm
- 打開(kāi)偏好荐糜,切換到
Language & Frameworks->PHP
, 會(huì)看到如下窗口:
PHP配置界面
- 點(diǎn)擊CLI Interpreter旁邊的
點(diǎn)點(diǎn)點(diǎn)
:
點(diǎn)擊點(diǎn)點(diǎn)點(diǎn)
- 點(diǎn)擊加號(hào)來(lái)添加mac上對(duì)應(yīng)的php解釋器的路徑:
添加php解釋器路勁
- 添加完畢后,會(huì)出現(xiàn)
Debugger: XDebug 2.5.1
添加完畢
點(diǎn)擊OK來(lái)應(yīng)用和關(guān)閉這個(gè)界面。
然后點(diǎn)開(kāi)
PHP->Debug
,填上XDebug的對(duì)應(yīng)信息:
填入XDebug的信息
- 打開(kāi)對(duì)應(yīng)的PHP項(xiàng)目并點(diǎn)擊導(dǎo)航條上的向下小箭頭的
edit configurations
:
點(diǎn)擊小箭頭
*找到PHP Remote Debug暴氏,點(diǎn)擊server旁邊的點(diǎn)點(diǎn)點(diǎn)延塑,進(jìn)行配置:
配置PHP Remote Debug -
在Ide Key上填入:PHPSTORM
填入Ide Key -
啟動(dòng)debug監(jiān)聽(tīng):
啟動(dòng)debug監(jiān)聽(tīng)
配置Chrome插件
- 安裝Chrome上對(duì)應(yīng)的XDebug插件:
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc -
安裝完畢后郵件Chrome上的XDebug插件,點(diǎn)擊選項(xiàng):
點(diǎn)擊選項(xiàng) -
在IDE KEY中選擇PhpStorm,并填入PHPSTORM(同IDE KEY)答渔,并點(diǎn)擊save
配置XDebug
Debug程序
-
啟動(dòng)對(duì)應(yīng)的Php程序
啟動(dòng)PHP程序 -
打開(kāi)頁(yè)面关带,并啟動(dòng)Chrome上的XDebug:
啟動(dòng)Debug -
刷新頁(yè)面,PHP STORM會(huì)彈出如下窗口:
收到監(jiān)聽(tīng) -
點(diǎn)擊Accept后就可以開(kāi)始快樂(lè)的給PHP程序打斷點(diǎn)了:
打斷點(diǎn)DEMO