1. 程式人生 > 其它 >macOS PhpStorm Xdebug 使用詳解

macOS PhpStorm Xdebug 使用詳解

場景

  • LNMP 位於 macOS
  • LNMP 位於 Docker
  • LNMP 位於虛擬機器中的 Docker

php-xdebug

安裝

# php也是通過brew安裝的

$ brew info php72-xdebug

$ brew install php72-xdebug

配置

/usr/local/etc/php/7.2/conf.d/ext-xdebug.ini

其他系統請替換為實際的路徑

[xdebug]
# 必須使用絕對路徑
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable=1
#xdebug.remote_host=local004.khs1994.com
xdebug.remote_connect_back=1
xdebug.remote_port=9010
xdebug.remote_log=/tmp/xdebug-remote.log
xdebug.remote_handler=dbgp

Chrome 外掛

https://github.com/mac-cain13/xdebug-helper-for-chrome

在選項中選擇 PhpStrom

FireFox 外掛

https://github.com/BrianGilbert/xdebug-helper-for-firefox

在選項中選擇 PhpStrom

PhpStrom 配置

  • File -> Settings -> Languages&Frameworks -> PHP -> Debug ->Xdebug Debug port: 9010 三個選項全部勾選(必須與擴充套件中配置的埠一致)。

使用

  • 設定斷點
  • 點選 電話 圖示(run -> Start listening for PHP…)
  • 瀏覽器開啟網址,點選 xdebug helper -》debug ,自動跳轉到 IDE

相關連結