【问题标题】:VsCode debugging on Ubuntu在 Ubuntu 上进行 VsCode 调试
【发布时间】:2020-03-29 10:49:05
【问题描述】:

在 ubuntu 19.10 上工作并尝试开始在 VScode 中调试我的代码,但在安装扩展程序后 - 没有任何效果(按钮被禁用)。

使用php7.3,在php.ini中添加了几行:

zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_port=9000`

已安装 apache2,但现在使用内置 Web 服务器 我的 php.ini 配置也看到了我添加的参数。 VScode 自己制作的 .json 文件是:

"version": "0.2.0",
"configurations": [
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }
]}

【问题讨论】:

    标签: php ubuntu visual-studio-code xdebug


    【解决方案1】:

    使用此配置

    zend_extension=<path_of_the_extension>
    xdebug.default_enable = 1
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1
    xdebug.remote_connect_back = 1
    xdebug.idekey = VSCODE
    xdebug.remote_handler = "dbgp"
    xdebug.remote_port = 9000
    xdebug.remote_log=/var/log/apache2/xdebug.log
    xdebug.remote_timeout = 500
    

    还要确保php.ini 文件是正确的,使用phpinfo(); 函数。第一行显示路径

    phpinfo()
    PHP Version => 7.4.7
    
    ...
    Server API => Command Line Interface
    Virtual Directory Support => disabled
    Configuration File (php.ini) Path => /etc/php/7.4/cli
    Loaded Configuration File => /etc/php/7.4/cli/php.ini
    ...
    

    在我的例子中,这个配置是用 /etc/php/7.4/mods-available/xdebug.ini 而不是 php.ini 编写的,因为 XDebug 是从存储库安装在 Ubuntu 中的

    【讨论】:

      猜你喜欢
      • 2020-09-25
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 2016-02-05
      • 2023-03-19
      • 2021-06-07
      • 2020-01-20
      • 1970-01-01
      相关资源
      最近更新 更多