Homestead 12.1.0 + VsCode Xdebug不生效的解決辦法

williamQian發表於2021-06-28

一、問題

Homestead使用的是 gitee.com/summerblue/homestead12.1.0版本,使用vscode的debug外掛設定斷點後,沒有在斷點處停下來,就是xdebug沒有監聽到請求,vscode的debug配置這樣寫的:
圖片

二、解決辦法

折騰半天才發現homestead的xdebug配置不對,用的還是老的配置,根據xdebug更新日誌 ,很多欄位改了。所以我們需要修改xdebug的配置。

  1. 開啟配置檔案
    #改成你實際使用的php版本,我這裡是7.4
    sudo vim /etc/php/7.4/fpm/conf.d/20-xdebug.ini
  2. 刪除如下配置:
    xdebug.remote_enable=1
    xdebug.remote_connect_back=1
    xdebug.remote_port=9000
  3. 加入下面的新配置
    xdebug.mode=debug
    xdebug.start_with_request=on
    xdebug.discover_client_host=on
    xdebug.client_port=9000
  4. 重啟fpm
    sudo service php7.4-fpm restart
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章