簡體   English   中英

將 Xdebug 與 PhpStorm 和 WSL 一起使用

[英]Use Xdebug with PhpStorm and WSL

我使用 Windows 10 中的 WSL (Ubuntu 16.14) 作為具有 PHP 7.1 fpm 和 Apache 的 Web 服務器。

我想將 PhpStorm 2018 中的 Xdebug 與 WSL 一起使用,但效果不佳。

Xdebug 安裝在我的 Ubuntu 服務器上並且運行良好,我在phpinfo()輸出中看到它。

這里是 Xdebug 的 php.ini 配置:

[Xdebug]
zend_extension="/usr/lib/php/20170718/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM

我也將phpstorm中的端口配置為9001。

問題更多在於 PhpStorm 和 WSL 之間的連接。 我嘗試使用遠程方式。 Run > Edit config彈出窗口中,我使用 PHP Web Page,當我使用 Validate 工具時,除了遠程主機之外一切正常。 我將其設置為 127.0.0.1,這就是重點。

聽調試工具提示:9001端口忙

如何在 localhost 和 localhost 之間建立鏈接?

我正在使用 Windows 10 中的 WSL(Ubuntu 20.04 LTS)作為帶有 PHP 7.4 fpm 的 Web 服務器和帶有 Xdebug 版本 3.0.4 的 Apache

以下是在 PHPSTORM 中配置 Xdebugger 的步驟,它適用於我:

  1. 安裝 Xdebug

  2. 在 cli 解釋器中選擇 wsl

  3. 要獲取 client_host,請在 ubuntu 中運行ifconfig或在 bash 中運行ipconfig

  4. 打開下面的文件

sudo vi /etc/php/7.4/cli/conf.d/20-xdebug.ini

在上面的文件中添加以下內容

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=[ip4 address/Client_host]
xdebug.remote_connect_back=On
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
xdebug.start_with_request=yes
xdebug.remote_log=/tmp/xdebug.log

  1. 然后使用 Xdebugger chrome 擴展(xdebugger helper)

  2. 重新啟動 apache 服務器。

  3. 給文件添加斷點並刷新頁面

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM