首页 > 解决方案 > 代客,重新启动 Big Sur 后的 Xdebug 无法正常工作

问题描述

在成功安装 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,
        }
    ]
}

这是 xdebug_info() 的输出

我该如何解决?

标签: phpvisual-studio-codexdebuglaravel-valetxdebug-3

解决方案


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

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

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

你能给我解释一下吗?

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


推荐阅读