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
如何正确设置VSCode和Wampserver,以便能够使用VSCode/PHP-XDebug/PHP-debug-debug扩展在断点行上进行调试和暂停?_Php_Visual Studio Code_Xdebug_Wampserver - Fatal编程技术网

如何正确设置VSCode和Wampserver,以便能够使用VSCode/PHP-XDebug/PHP-debug-debug扩展在断点行上进行调试和暂停?

如何正确设置VSCode和Wampserver,以便能够使用VSCode/PHP-XDebug/PHP-debug-debug扩展在断点行上进行调试和暂停?,php,visual-studio-code,xdebug,wampserver,Php,Visual Studio Code,Xdebug,Wampserver,我需要做什么来解决这个问题,防止我使用php上的xdebug扩展在VSCode 1.51.0上进行调试,以及Felix Becker在VS Code上的php调试扩展V1.13.0 httpd.conf # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78

我需要做什么来解决这个问题,防止我使用php上的xdebug扩展在VSCode 1.51.0上进行调试,以及Felix Becker在VS Code上的php调试扩展V1.13.0

httpd.conf

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 81
# Virtual Hosts
#
<VirtualHost *:81>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


#
<VirtualHost *:81>
    ServerName portaldev
    DocumentRoot "c:/wamp64/www/portaldev"
    <Directory  "c:/wamp64/www/portaldev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

#
<VirtualHost *:81>
    ServerName portallive
    DocumentRoot "c:/wamp64/www/liveportal"
    <Directory  "c:/wamp64/www/liveportal/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80     <------------- Changed to 80 instead of 81
# Virtual Hosts

<VirtualHost *:80>    <------ Set to port 80
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


#
<VirtualHost *:80>   <------ Set to port 80
    ServerName portaldev
    DocumentRoot "c:/wamp64/www/portaldev"
    <Directory  "c:/wamp64/www/portaldev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

#
<VirtualHost *:80>    <------ Set to port 80
    ServerName portallive
    DocumentRoot "c:/wamp64/www/liveportal"
    <Directory  "c:/wamp64/www/liveportal/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
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",
            // Change back to php
            "type": "php",
            "request": "launch",
            "hostname": "localhost",
            "port": 81,
            "log": true,
            // Deprecated 
            // "localSourceRoot": "/var/www/html/mysite",
            // "serverSourceRoot": "/var/www/html/mysite",
            // server -> local
            "stopOnEntry": true,
            // "cwd": "${fileDirname}"
        },
        {
            "type": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://portaldev/",
            "webRoot": "${workspaceFolder}"
        }
    ]
}
{
    // 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",
            "port": 9000,  <----- Modified to default XDebug port 9000
            "request": "launch",
            "pathMappings": {
                "c:/wamp64/www/portaldev/": "${workspaceFolder}"
            }
        }
    ]
}
Visual Studio控制台中出现错误-以管理员身份运行

  <- outputEvent
    OutputEvent {
      seq: 0,
      type: 'event',
      event: 'output',
      body: {
        category: 'console',
        output: 'Error: listen EACCES: permission denied 127.0.0.1:81\n' +
          '    at Server.setupListenHandle [as _listen2] (net.js:1289:21)\n' +
          '    at listenInCluster (net.js:1354:12)\n' +
          '    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1493:7)\n' +
          '    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:65:10) {\n' +
          "  code: 'EACCES',\n" +
          "  errno: 'EACCES',\n" +
          "  syscall: 'listen',\n" +
          "  address: '127.0.0.1',\n" +
          '  port: 81\n' +
          '}\n'
      }
    }
    Error: listen EACCES: permission denied 127.0.0.1:81
        at Server.setupListenHandle [as _listen2] (net.js:1289:21)
        at listenInCluster (net.js:1354:12)
        at GetAddrInfoReqWrap.doListen [as callback] (net.js:1493:7)
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:65:10) {
      code: 'EACCES',
      errno: 'EACCES',
      syscall: 'listen',
      address: '127.0.0.1',
      port: 81
    }
    <- launchResponse
    Response {
      seq: 0,
      type: 'response',
      request_seq: 2,
      command: 'launch',
      success: false,
      message: 'listen EACCES: permission denied 127.0.0.1:81',
      body: {
        error: {
          id: 0,
          format: 'listen EACCES: permission denied 127.0.0.1:81',
          showUser: true
        }
      }
    }

我解决了问题,并让应用程序在应用程序中指定的断点处停止

注意到原始问题第一条评论中的建议后,我在php.ini中将我的XDebug广播端口更改为9000,并在我的项目目录中将我的启动配置json文件设置为收听9000,并设置myphp.ini
xdebug.remote\u port=“9000”
,以及
xdebug.remote\u mode=“req”
。然后在httpd.conf中将我的侦听端口设置为80,并在httpd vhosts.conf中将所有虚拟主机端口设置为80

启动浏览器后,我启动了调试器,方法是转到VS代码,单击(运行,然后单击调试(或按键盘上的F5),IDE在最初设置的断点处停止(这是通过单击源代码行号左侧并观察一个出现为断点的鲜红色圆圈或圆点来完成的

浅灰色但空心的圆圈,或浅红色或粉红色的圆圈不是要调试的测试的正确断点

httpd.conf

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 81
# Virtual Hosts
#
<VirtualHost *:81>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


#
<VirtualHost *:81>
    ServerName portaldev
    DocumentRoot "c:/wamp64/www/portaldev"
    <Directory  "c:/wamp64/www/portaldev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

#
<VirtualHost *:81>
    ServerName portallive
    DocumentRoot "c:/wamp64/www/liveportal"
    <Directory  "c:/wamp64/www/liveportal/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80     <------------- Changed to 80 instead of 81
# Virtual Hosts

<VirtualHost *:80>    <------ Set to port 80
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


#
<VirtualHost *:80>   <------ Set to port 80
    ServerName portaldev
    DocumentRoot "c:/wamp64/www/portaldev"
    <Directory  "c:/wamp64/www/portaldev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

#
<VirtualHost *:80>    <------ Set to port 80
    ServerName portallive
    DocumentRoot "c:/wamp64/www/liveportal"
    <Directory  "c:/wamp64/www/liveportal/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
#将此更改为侦听特定IP地址,如下所示
#防止Apache欺骗所有绑定的IP地址。
#
#听12.34.56.78:80

听80请检查Xdebug文档,了解Xdebug端口是什么以及它是如何工作的。简言之:1)是Xdebug连接到调试客户端(代码中的VSCode),而不是其他方式2)Xdebug端口必须与您的网站端口不同。
“端口”:81,
在这里是错误的——当您的Apache已经在使用端口81时,您不能告诉VSCode侦听端口81。它必须与php中的端口相同。ini@LazyOne,谢谢你的提示,我现在发布了我问题的完整答案。你可以保留Apache的
81
,这很好(是的,80是默认值,因此更方便,因为您不必显式地将其声明为URL的一部分)。Xdebug端口必须有所不同。默认情况下,它是9000,并且可能与系统上安装的
php fpm
相冲突(但在Linux/Mac上,而不是在Windows上).Xdebug 3将默认使用9003。