【问题标题】:Valet, Xdebug after reboot Big Sur not working代客,重新启动 Big Sur 后的 Xdebug 无法正常工作
【发布时间】:2021-09-29 23:01:32
【问题描述】:

在成功安装 Valet、Xdebug 并为 Xdebug 3 的 Listener 配置 VSCODE 并检查一切正常后,在第一次关闭和打开 mac(操作系统:Big Sur)时,Xdebug 开始停止工作。

我尝试使用命令重启代客

valet restart

但 Xdebug 仍然无法正常工作。

PHP 和 Xdebug 的版本:

/usr/local/bin/php -v
PHP 7.4.21 (cli) (built: Jul 12 2021 11:57:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

PHP 初始化:

php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/error_log.ini,
/usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/ext-xdebug.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini

配置 Xdebug ini:

# Configuration for Xdebug 3
[Xdebug]
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.start_with_request=default
xdebug.idekey=VSCODE
xdebug.client_port=9003
xdebug.client_host=127.0.0.1
xdebug.start_upon_error=yes
xdebug.discover_client_host=1

VSCODE 设置.json

{
    "php.validate.executablePath": "/usr/bin/php",
    "intelephense.environment.phpVersion": "7.4",
    "intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true,
    "grunt.autoDetect": "on",
    "artisan.php.location": "/usr/local/bin/php"
}

配置 myproject/.vscode/lunch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
        }
    ]
}

This is the output of xdebug_info()

我该如何解决?

【问题讨论】:

标签: php visual-studio-code xdebug laravel-valet xdebug-3


【解决方案1】:

在寻找解决方案 3 小时后,我安装了两个扩展程序,一个用于 Google Chrome,一个用于 Safari,Xdebug 神奇地恢复了工作。

我不明白为什么我必须在浏览器上安装扩展程序(Safari ExtensionChrome Extension)才能使 Xdebug 工作。

在 Xdebug 工作之前没有在各种浏览器上安装扩展。这怎么可能?

你能给我解释一下吗?

如何避免在浏览器上使用扩展来使 Xdebug 工作?

【讨论】:

  • start_with_request=defaultmode=debugtrigger 相同时。 Xdebug 浏览器扩展实际上是在添加那个触发器(Xdebug cookie)——当它出现在请求中时,它意味着“看,这个请求需要调试”。
  • 感谢@LazyOne 的回复,但我仍然不清楚在没有安装插件之前它是如何工作的。
  • 你可能有其他的东西: 1) Xdebug cookie 或 GET/POST 参数充当“调试我”标志; 2) Xdebug 配置可能有点不同(“调试每个请求,不要寻找标志”); 3) ENV 中的一些 Xdebug 参数(在 Valet/服务器端;影响“调试我”标志)在重新启动之前存在。我只能猜测,因为我不知道你到底在做什么......而且你总是有可能错过或忘记了一些步骤(我们都会在短期内犯错误而没有意识到它们)。
  • @LazyOne 您的问题的答案: 1. 没有激活“调试我”标志的 Xdebug cookie 或 GET / POST 参数。 2.如何激活“调试每个请求,不找标志”? 3. 我在ENV中没有Xdebug的参数,我只有Laravel的默认参数。
猜你喜欢
  • 2021-03-02
  • 1970-01-01
  • 1970-01-01
  • 2021-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-26
  • 1970-01-01
相关资源
最近更新 更多