【问题标题】:Debug PHP in CLI mode using Xdebug and PHP Debug extension使用 Xdebug 和 PHP Debug 扩展在 CLI 模式下调试 PHP
【发布时间】:2020-07-04 08:37:35
【问题描述】:

我无法从 localhost 上的 CLI 设置调试(在 PHP Debug 中启动当前打开的脚本配置) 脚本运行,但忽略任何断点。 否则,在浏览器中调试 PHP 可以正常工作。

我的设置,launch.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": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9000,
            "stopOnEntry": true,
            "hostname": "localhost",
            "runtimeExecutable": "C:\\wamp64\\bin\\php\\php7.4.1\\php.exe",
            "env": {"XDEBUG_CONFIG" : "remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"
            },
            "runtimeArgs": ["-dxdebug.remote_enable=1", "-dxdebug.remote_mode=req",  "-dxdebug.remote_port=9000", "-dxdebug.remote_host=127.0.0.1", "-dxdebug.remote_connect_back=0"
            ]
        }
    ]
}

php.ini 中的 Xdebug 部分:

[xdebug]
zend_extension="c:/wamp64/bin/php/php7.4.1/zend_ext/php_xdebug-2.9.0-7.4-vc15-x86_64.dll"
xdebug.remote_enable = On
;xdebug.remote_autostart = 1
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.remote_log = "c:/wamp64/tmp"
;xdebug.remote_host=localhost

正如您从设置中看到的那样,我尝试尝试不同的设置,但无济于事。

编辑:这是调试的日志文件:

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true
}

<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body: { category: 'stdout', output: 'gotovo!' }
}

gotovo!
<- terminatedEvent
TerminatedEvent { seq: 0, type: 'event', event: 'terminated' }

-> disconnectRequest
{
  command: 'disconnect',
  arguments: { restart: false },
  type: 'request',
  seq: 3
}

【问题讨论】:

    标签: php debugging visual-studio-code command-line-interface xdebug


    【解决方案1】:

    您在终端 cli 上没有相同的可能性, 因为你不使用 php 模块。 这里只在服务器apache或者nginx里面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-26
      • 1970-01-01
      • 2019-12-09
      • 2010-12-29
      • 1970-01-01
      • 2010-09-16
      • 2021-06-14
      • 2010-10-16
      相关资源
      最近更新 更多