Visual Studio代码PHP调试不起作用 [英] visual studio code PHP debugging not working

查看:215
本文介绍了Visual Studio代码PHP调试不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 VS Code PHP调试器



我正在使用xampp。



我尝试以两种方式(监听和启动)运行代码。



Listen 坐在那里,而Launch在调试控制台中显示 spawn php ENOENT



这是我的launch.json。

  {
版本: 0.2.0,
配置:[

{
name:收听XDebug,
type : php,
request:启动,
port:9000
},
{
name:启动当前打开的脚本,
type: php,
request: launch,
program: $ {file},
cwd: $ {fileDirname},
port:9000
}
]
}

我在做什么错了?

解决方案

现在就做:


  1. 我们有带有Microsoft Visual Code的OS Windows ,并且已经安装了< PHP Debug 模块


    1. 打开 php.ini指令中显示的总是有很多php.ini-apache文件夹中有一个php.ini,php中有php.ini和phpForApache.ini。但是phpinfo清楚地显示出确实使用了哪个



      2.1。并使用 xdebug.remote_enable = 1 xdebug.remote_autostart = 1 。我的工作示例:

        [XDebug] 
      zend_extension = c:\wamp64\bin\php\ \php7.1.9\ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll
      xdebug.stopOnEntry = true
      xdebug.profiler_enable =关闭
      xdebug.profiler_enable_trigger =关闭
      xdebug.profiler_output_name = cachegrind.out。%t。%p
      xdebug.profiler_output_dir = c:/ wamp64 / tmp
      xdebug.show_local_vars = 0
      ; xdebug.profiler_output_name = cachegrind.out。%t-%s
      xdebug.remote_enable = 1
      xdebug.remote_autostart = 1
      xdebug.remote_handler = dbgp
      xdebug.remote_host = 127.0.0.1
      xdebug.remote_log = C:\wamp64\tmp\xdebug.txt
      xdebug.remote_port = 9000
      xdebug.trace_output_dir = C:\wamp64 \tmp
      xdebug.remote_cookie_expire_time = 36000


    2. 重新启动Apache2 Web服务器。


    也:



    对于某些人我首先让xdebug在Netbeans上进行测试的原因,然后才在手册中找到选项 xdebug.remote_autostart = 1 使其也可以在VS Code中工作。



    如果不确定XDebug的安装,请检查phpinfo页面中的 with Xdebug字样,并检查 logs / apache_errors.log 中的加载php_xdebug失败(下载了错误的DDL)。然后与其他任何IDE一起检查。



    问候!


    I have installed VS Code and the PHP debugger.

    I am using xampp.

    I tried running the code (2) ways (listen and launch).

    Listen just sits there while Launch shows spawn php ENOENT in the debug console.

    This is my launch.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
            }
        ]
    }
    

    What am I doing wrong?

    解决方案

    Made it just now:

    1. We have OS Windows with Microsoft Visual Code and we have installed 'PHP Debug' module https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug#overview Steps to make it working already wroten here, but I'll write again:

    2. Install XDebug. Online Wizard https://xdebug.org/wizard.php helps you, just post here phpinfo() data. Save in phpinfo.php this:

      <?php phpinfo(); ?>
      

    then open in browser localhost/phpinfo.php, copy everything you see (Ctrl+A then Ctrl+C) to wizard. It shows you obtained info and steps to do:

    1. Open shown in instruction php.ini (there are always many php.ini - apache folder has one php.ini, php has php.ini and phpForApache.ini. But phpinfo makes it clear showing which one is really used)

      2.1. and configure it with xdebug.remote_enable = 1 and xdebug.remote_autostart = 1. My working example:

      [XDebug]
      zend_extension = "c:\wamp64\bin\php\php7.1.9\ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"    
      xdebug.stopOnEntry = true
      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.profiler_output_name = "cachegrind.out.%t-%s"
      xdebug.remote_enable = 1
      xdebug.remote_autostart = 1
      xdebug.remote_handler = "dbgp"
      xdebug.remote_host = "127.0.0.1"
      xdebug.remote_log = "C:\wamp64\tmp\xdebug.txt"
      xdebug.remote_port = 9000
      xdebug.trace_output_dir = "C:\wamp64\tmp"
      xdebug.remote_cookie_expire_time = 36000
      

    2. Restart Apache2 webserver.

    Also:

    For some reason I first got xdebug working on Netbeans for testing, and only then I found option xdebug.remote_autostart = 1 in manual that made it working in VS Code also.

    If you are unsure about XDebug installation, check phpinfo page for "with Xdebug" words and check logs/apache_errors.log for "failed loading php_xdebug" (incorrect DDL downloaded). Then check with any other IDE.

    Good regards!

    这篇关于Visual Studio代码PHP调试不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆