【问题标题】:PHP Xdebug doesn't debug on xamppPHP Xdebug 不在 xampp 上调试
【发布时间】:2020-05-19 13:33:28
【问题描述】:

当我尝试调试我的 php 代码时,我得到了错误:

Error: spawn php ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn php',
  path: 'php',
  spawnargs: [
    'c:\\xampp\\htdocs\\fantatools\\wordpress\\wp-content\\themes\\feisar\\api\\calendario.php'
  ]
}

我按照 xdebug 向导的说明进行操作,但仍然无法正常工作:

  • 下载php_xdebug-2.9.1-7.3-vc15-x86_64.dll
  • 将下载的文件移动到C:\xampp\php\ext
  • 编辑C:\xampp\php\php.iniC:\WINDOWS\php.ini并添加行 zend_extension = C:\xampp\php\ext\php_xdebug-2.9.1-7.3-vc15-x86_64.dll
  • 确保zend_extension = C:\xampp\php\ext\php_xdebug-2.9.1-7.3-vc15-x86_64.dll 低于 OPcache 行。
  • 重启网络服务器

【问题讨论】:

  • "Edit C:\xampp\php\php.ini C:\WINDOWS\php.ini" — 向导应该给你一个文件,而不是两个。真的有2吗?此外,Xdebug 是否出现在您的正常phpinfo() 输出中? PHP 在路径上吗?您从 VSCode 得到的错误表明它不是。

标签: php debugging xampp xdebug


【解决方案1】:

我有同样的错误信息,但使用 xdebug 3.0.1,结果证明设置 xdebug 的传统方法已经改变。目前启动xdebug3如下:

VS 代码(launch.js)

  {
        // 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,
                "pathMappings": {
                    "your filepath": "${workspaceRoot}",
                }
            }
        ]
    }

PHP INI

[xdebug]
zend_extension="your xdebug library"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true

您将在此链接中找到更多信息:https://github.com/felixfbecker/vscode-php-debug/issues/411

【讨论】:

    猜你喜欢
    • 2020-11-21
    • 2015-11-30
    • 1970-01-01
    • 2015-07-07
    • 2019-05-27
    • 2011-01-11
    • 1970-01-01
    • 2013-01-14
    • 2016-06-25
    相关资源
    最近更新 更多