Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么XDebug导致页面在VisualStudio代码PHP调试扩展中无法加载?_Php_Visual Studio Code_Xdebug - Fatal编程技术网

为什么XDebug导致页面在VisualStudio代码PHP调试扩展中无法加载?

为什么XDebug导致页面在VisualStudio代码PHP调试扩展中无法加载?,php,visual-studio-code,xdebug,Php,Visual Studio Code,Xdebug,我正在尝试在VisualStudio代码中调试php。这是我安装PHP调试扩展(以及PHP和XDebug作为依赖项)之后的第一个项目。如果在命令提示符“C:\PHP>PHP-s0.0.0:9000 C:\users\landerson\documents\vs\u proj\PHP\u example\index.PHP”中有PHP可执行文件,则页面将正确呈现。但是,如果我在VisualStudio中使用配置“Listenforxdebug”开始调试,则页面将一直处于加载状态,直到我停止调试过程

我正在尝试在VisualStudio代码中调试php。这是我安装PHP调试扩展(以及PHP和XDebug作为依赖项)之后的第一个项目。如果在命令提示符“C:\PHP>PHP-s0.0.0:9000 C:\users\landerson\documents\vs\u proj\PHP\u example\index.PHP”中有PHP可执行文件,则页面将正确呈现。但是,如果我在VisualStudio中使用配置“Listenforxdebug”开始调试,则页面将一直处于加载状态,直到我停止调试过程

下面是Microsoft解释初始设置的博客条目:。我怀疑没有完全理解“确保将您的Web服务器根指向您的项目,并且每次请求一个PHP文件”的说明可能会让我感到困惑。我尝试过使用和不使用命令提示符条目。这似乎只会影响我停止调试过程后发生的事情。我已将phpinfo()结果输入并按照说明操作。我在C:\php中既没有index.php也没有php.ini,在C:\users\landerson\documents\vs\u proj\php\u示例中也没有

index.php

<?php
$myvar = "Hello ";
$myvar = $myvar . "PHP World!";

echo $myvar;

?>
C:\Users\landerson\AppData\Roaming\Code\User\settings.json

{
    //"http.proxyStrictSSL": false,

    "php.validate.enable": true,
    "php.validate.executablePath": "C:\\php\\php.exe",
    "php.validate.run": "onType"
}
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
        }
    ]
}
{
    // 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}",
            "port": 9000
        }
    ]
}

我希望页面至少在没有断点的情况下加载,添加断点将利用PHP调试扩展。Visual Studio代码似乎至少让XDebug开始在端口9000上侦听,但无论出于何种原因,它都没有按预期进行。

因此,我通过以下视频完成了它的工作:Lyall van der Linde。在其他错误中,我不应该将服务和扩展配置到同一个端口

就目前我所知,XDebug还没有针对PHP32位版本7.3.1的版本,所以我最终安装了旧版本的XAMPP(7.2.14)。旧版本的Windows installer可从以下站点获得:。我已经安装了Visual Studio代码的最新版本。我已经将PHP调试扩展添加到Visual Studio代码中,并重新加载了应用程序

由于IIS使用的是端口80,我打开XAMPP控制面板并导航到主级配置,然后是服务和端口设置,并在apache选项卡下将服务名称Apahce2.4设置为主端口8080和SSL端口443。我编辑了C:\xampp\apache\conf\httpd.conf并将“Listen 80”替换为“Listen 8080”。然后,我在XAMPP控制面板中启动了apache服务

然后,我在C:\xampp\htdocs\下添加了文件夹“phptest”,并在VSCode中打开了该文件夹。添加文件test.php并添加行:

<?php

$a = 6;
$b = 3;
$c = 0;

$c = $a * $b;

echo $c;
我打开的输出为“18”

我打开、复制了该页面的文本,并将结果粘贴到输入表单中。这促使我为XDebug下载了正确的dll(php_XDebug-2.6.1-7.2-vc15.dll)。然后,我编辑了C:\xampp\php\php.ini并将其附加到文件末尾:

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
zend_extension = C:\xampp\php\ext\php_xdebug-2.6.1-7.2-vc15.dll
由于php.ini的变化,我需要停止并重新启动XAMPP控制面板中的Apache服务。然后,我在VisualStudio代码的左侧导航下选择了“Debug”,并添加了一个PHP配置“listenforxdebug”,并使用了默认的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
        }
    ]
}
{
    // 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}",
            "port": 9000
        }
    ]
}
我在test.php中添加了一个断点,并开始在Visual Studio代码中进行调试。我在浏览器中导航到localhost:8080/phptest/test.php,我的断点在Visual Studio代码中被击中,允许我查看变量值并逐步完成代码