本文為 PhpStorm 8.x + PHP 5.6 + Xdebug 2.2.5 環境下的詳細調試配置指南,新版操作邏輯一致,介面略有差異。
[xdebug]
zend_extension="D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
驗證:phpinfo() 出現 Xdebug 區塊。

Settings → Languages & Frameworks → PHP → Debug,Port = 9000。

Run → Edit Configurations → + → PHP Web Application
Name: 專案名,Server: 新增/選擇 localhost:80 Xdebug,Start URL: 你的本地站點。

在 Server 設定中勾選 Use path mappings,將本地專案目錄對應到伺服器 DocumentRoot。

Shift+F9。
$i > 100)再次點擊甲蟲圖示(變紅)或 Ctrl+F2,關閉 Debug 面板回到編輯視圖。
掌握 PhpStorm + Xdebug 除錯流程,能大幅縮短定位 Bug 時間,是 PHP 開發者必備技能。