瀏覽 Xdebug Wizard,貼上 phpinfo() 輸出的 HTML,即可獲得精確的下載連結(需符合 PHP 版本、VC 編譯器、Thread Safe 與架構)。
php_xdebug-.dll 至 PHP 擴充目錄(如 D:\php\ext\)。php.ini,新增:zend_extension = "D:\php\ext\php_xdebug-.dll"
; 基本除錯 xdebug.default_enable = 1 xdebug.show_exception_trace = 1 xdebug.show_local_vars = 1 xdebug.max_nesting_level = 256 ; 變數顯示深度 xdebug.var_display_max_depth = 6 xdebug.var_display_max_children = 256 xdebug.var_display_max_data = 1024 ; Profiling 效能分析 xdebug.profiler_enable = 1 xdebug.profiler_output_dir = "D:\php\xdebug_profiler" xdebug.profiler_output_name = "cachegrind.out.%p" ; 遠端除錯 xdebug.remote_enable = 1 xdebug.remote_host = "localhost" xdebug.remote_port = 9000 xdebug.remote_autostart = 0 xdebug.remote_connect_back = 0 xdebug.idekey = "PHPSTORM"
| 參數 | 預設 | 說明 |
|---|---|---|
| xdebug.max_nesting_level | 100 | 限制遞迴深度,防止無限遞迴導致崩潰。 |
| xdebug.show_local_vars | 0 | 錯誤堆疊中顯示所有區域變數(資訊量大,慎用)。 |
| xdebug.profiler_enable | 0 | 開啟效能分析,產生 CacheGrind 相容檔案。 |
| xdebug.remote_enable | 0 | 啟用遠端除錯,需搭配 IDE(如 PhpStorm、VS Code)。 |
zend_extension 行,否則 Xdebug 無法載入。php.ini 後必須重啟 Apache / Nginx / PHP-FPM。