xdebug+ vscode+ php+ Wampserver:Breakpoint在调试会话的开始时未击中

发布于 2025-01-25 00:11:58 字数 2694 浏览 2 评论 0原文

不久前,我成功解决了这个问题:

如何使用vscode / php xdebug / php debug扩展扩展名,如何正确设置VSCODE和WAMPSERVER,以便能够在断点线上进行调试和暂停?

现在,我拥有最新的PHP 8 vscode和xdebug 3,但是我的API中没有击中我的断点,它以自定义主机名从local -Host(虚拟主机)重命名为node.js reactjs app(on on )风险aim:3000,在php api服务器上运行strigaim:9003),

我无法让VSCODE调试器停止在我设置了一个断点的线路上。

我该如何解决?

这是我的设置:

php.ini的底部 c:/wamp64/bin/apache/php/php/apache2.4.46/bin/php.ini

; XDEBUG Extension
[xdebug]
zend_extension="c:/wamp64/bin/php/php8.0.9/ext/php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_mode = "req" 
xdebug.mode = debug       
xdebug.client_port = "9003"
xdebug.remote_log = "c:/wamp64/tmp/log"
xdebug.show_local_vars = 0
xdebug.idekey = vsc

settings.json

{
    "php.executablePath": "C:/wamp64/bin/php/php8.0.9/php.exe",
}

启动

 {
        // 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
            }
        ]
    }

httpd.conf

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# 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 9003

httpd-vhosts.confs.conf

# Virtual Hosts
#

<VirtualHost *:9003>
  ServerName localhost
  DocumentRoot "${INSTALL_DIR}/www/"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>




<VirtualHost *:9003>
    ServerName riskaim
    DocumentRoot "${INSTALL_DIR}/www/RiskAIM/"
    <Directory  "${INSTALL_DIR}/www/RiskAIM/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

A while back I succeeded at resolving this problem:

How to properly setup VSCode and Wampserver to be able to debug and pause on breakpoint line, using VSCode / PHP XDebug / PHP Debug Extension?

Now I have PHP 8 with the latest VSCode and Xdebug 3, but my breakpoint is not hit in my API, which runs with a custom host name renamed from localhost (virtual host) in back of a Node.js ReactJS app (on riskaim:3000, where as the PHP API server is running on riskaim:9003)

I can't get the VSCode debugger to stop on the line on which I have set a breakpoint.

How do I resolve this?

Here are my settings:

Bottom of php.ini
c:/wamp64/bin/apache/php/apache2.4.46/bin/php.ini

; XDEBUG Extension
[xdebug]
zend_extension="c:/wamp64/bin/php/php8.0.9/ext/php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_mode = "req" 
xdebug.mode = debug       
xdebug.client_port = "9003"
xdebug.remote_log = "c:/wamp64/tmp/log"
xdebug.show_local_vars = 0
xdebug.idekey = vsc

settings.json

{
    "php.executablePath": "C:/wamp64/bin/php/php8.0.9/php.exe",
}

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": 9003
            }
        ]
    }

Middle of httpd.conf

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# 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 9003

httpd-vhosts.conf

# Virtual Hosts
#

<VirtualHost *:9003>
  ServerName localhost
  DocumentRoot "${INSTALL_DIR}/www/"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>




<VirtualHost *:9003>
    ServerName riskaim
    DocumentRoot "${INSTALL_DIR}/www/RiskAIM/"
    <Directory  "${INSTALL_DIR}/www/RiskAIM/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2025-02-01 00:11:58

事实证明,我在我的API文件夹的.htaccess文件中添加了一条不必要的行。删除此行解决了问题,调试器步骤光标开始成功地工作。

更改

RewriteBase /
RewriteEngine On
Options -Indexes
DirectoryIndex api.php

RewriteCond %{REQUEST_URI} ^/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SERVER_PORT}=80            <-------------- I removed this line and it the debugger started stepping through the code on my first api get request
RewriteRule ^(.*)$ /api/api.php?requestPath=$1 [L,QSA]

ErrorDocument 403  "<meta http-equiv='refresh' content='0; url=//riskaim:3000' />"
ErrorDocument 404  "<meta http-equiv='refresh' content='0; url=//riskaim:3000' />"

   [xdebug]
    zend_extension="c:/wamp64/bin/php/php8.0.9/zend_ext/php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
    xdebug.mode = develop,debug
    xdebug.start_with_request = yes
    xdebug.client_host = localhost
    xdebug.client_port = "9003"
    xdebug.idekey = vsc

 {
        // 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": "Launch Chrome",
                "request": "launch",
                "type": "chrome",
                "url": "http://riskaim:3000",
                "webRoot": "${workspaceFolder}"
            },      
            {
                "name": "Listen for Xdebug",
                "type": "php",
                "request": "launch",
                "port": 9003,
                "hostname": "riskaim",
                "pathMappings": {
                    "c:\\wamp64\\www\\riskaim": "${workspaceRoot}"
                }
            }
        ]
    }

Listen 80  <------------ changed from Listen 9003 (incorrect)

<VirtualHost *:80>   <----------------changed from *:9003
    ServerName riskaim
    DocumentRoot "${INSTALL_DIR}/www/RiskAIM/"
    <Directory  "${INSTALL_DIR}/www/RiskAIM/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

It turns out I had added an unnecessary line in my .htaccess file of my api folder. Removal of this line fixed the problem and the debugger step cursor started working successfully.

Changes made

.htaccess

RewriteBase /
RewriteEngine On
Options -Indexes
DirectoryIndex api.php

RewriteCond %{REQUEST_URI} ^/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SERVER_PORT}=80            <-------------- I removed this line and it the debugger started stepping through the code on my first api get request
RewriteRule ^(.*)$ /api/api.php?requestPath=$1 [L,QSA]

ErrorDocument 403  "<meta http-equiv='refresh' content='0; url=//riskaim:3000' />"
ErrorDocument 404  "<meta http-equiv='refresh' content='0; url=//riskaim:3000' />"

Bottom of php.ini (c:/wamp64/bin/apache/apache2.4.46/bin/php.ini)

   [xdebug]
    zend_extension="c:/wamp64/bin/php/php8.0.9/zend_ext/php_xdebug-3.0.4-8.0-vs16-x86_64.dll"
    xdebug.mode = develop,debug
    xdebug.start_with_request = yes
    xdebug.client_host = localhost
    xdebug.client_port = "9003"
    xdebug.idekey = vsc

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": "Launch Chrome",
                "request": "launch",
                "type": "chrome",
                "url": "http://riskaim:3000",
                "webRoot": "${workspaceFolder}"
            },      
            {
                "name": "Listen for Xdebug",
                "type": "php",
                "request": "launch",
                "port": 9003,
                "hostname": "riskaim",
                "pathMappings": {
                    "c:\\wamp64\\www\\riskaim": "${workspaceRoot}"
                }
            }
        ]
    }

httpd.conf Middle of file

Listen 80  <------------ changed from Listen 9003 (incorrect)

httpd-vhosts.conf

<VirtualHost *:80>   <----------------changed from *:9003
    ServerName riskaim
    DocumentRoot "${INSTALL_DIR}/www/RiskAIM/"
    <Directory  "${INSTALL_DIR}/www/RiskAIM/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文