簡體   English   中英

Xdebug + VSCode + PHP + WampServer:調試開始時未命中斷點 session

[英]Xdebug + VSCode + PHP + WampServer : breakpoint not hit on start of debug session

前一段時間我成功地解決了這個問題:

如何使用 VSCode / PHP XDebug / PHP Debug Extension 正確設置 VSCode 和 Wampserver 以便能夠在斷點行進行調試和暫停?

現在我有 PHP 8 和最新的 VSCode 和 Xdebug 3,但我的斷點沒有在我的 API 中運行,它使用從 Node.js ReactJS 應用程序后面的localhost (虛擬主機)重命名的自定義主機名運行(在riskaim:3000上,其中 PHP API 服務器在riskaim:9003上運行)

我無法讓 VSCode 調試器停在我設置了斷點的行上。

我該如何解決這個問題?

這是我的設置:

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

設置.json

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

啟動.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
            }
        ]
    }

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>

事實證明,我在.htaccess文件夾的 .htaccess 文件中添加了一個不必要的行。 刪除此行解決了問題,調試器步驟 cursor 開始成功運行。

所做的更改

.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' />"

底部 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

啟動.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 文件中間

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM