【问题标题】:Debug not working in PhpStorm with server on VM使用 VM 上的服务器在 PhpStorm 中调试不起作用
【发布时间】:2021-12-18 12:53:42
【问题描述】:

我在 VirtualBox 上设置了自己的 Debian 服务器,一切正常,除了 Xdebug 无法启动。在服务器上,我有 Symfony 3 应用程序,它使用 vhost admin.localwww.pl 和 HTTPS。

我的php -v 结果:

PHP 7.3.31-2+0~20211022.89+debian11~1.gbp745ac7 (cli) (built: Oct 22 2021 12:37:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.31-2+0~20211022.89+debian11~1.gbp745ac7, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans

我的 xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9003
xdebug.idekey = PHPSTORM
xdebug.mode=debug
xdebug.show_error_trace = 1
xdebug.remote_autostart = 1

我的 PhpStorm 设置:

当我运行 PHP 远程调试配置时,我看到:

无论我在 URL 中添加 ?XDEBUG_SESSION_START=PHPSTORM 还是在 Google Chrome 中使用 Xdebug Helper,效果都是一样的:尽管设置了断点,但什么也没有发生。

我在 VM 上的远程服务器上使用 PHP CLI:


编辑:我当前的配置,但仍然无法正常工作:

zend_extension=xdebug.so
xdebug.idekey=PHPSTORM
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port = 9003

【问题讨论】:

  • PHPStorm 是否在虚拟机上运行?还是 PHP 在 VM 上运行,PHPstorm 在主机上运行?
  • @viko PHP Storm 在主机上,PHP+nginx+php-fpm 在虚拟机上
  • PHP xdebug 必须与主机连接。所以client_host 参数应该去主机。请尝试从 VM ping 主机并在此参数中使用此 IP/主机名。我猜应该是:xdebug.client_host = 10.0.2.2
  • @viko 当我重新启动服务器时一切正常:D
  • @PawelC - 酷 :) 不客气 -> miłej zabawy。

标签: php phpstorm xdebug


【解决方案1】:

您的所有设置均参考 Xdebug 2 设置,您使用的是 Xdebug 3.1.1 — 请阅读升级指南:https://xdebug.org/docs/upgrade_guide

【讨论】:

  • 这个配置没问题 zend_extension=xdebug.so xdebug.idekey=PHPSTORM xdebug.mode=develop,debug xdebug.start_with_request=yes xdebug.client_host=127.0.0.1 xdebug.client_port = 9003
  • 我已经这样做了,我将页面文件保存在 macOS 上,服务器在 Virtualbox 上,并且带有页面的目录使用共享文件夹连接到它
【解决方案2】:

请在任何页面上使用函数 xdebug_info() 来接收诊断数据。 另外请设置 xdebug_log。

【讨论】:

  • [903] [Step Debug] ERR:无法连接到调试客户端。已尝试:127.0.0.1:9003(通过 xdebug.client_host/xdebug.client_port):-( [903] [Step Debug] INFO:连接到配置的地址/端口:127.0.0.1:9003。
  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-14
  • 1970-01-01
  • 2020-04-09
  • 1970-01-01
  • 1970-01-01
  • 2014-08-28
  • 2012-09-03
相关资源
最近更新 更多