为什么不在 PHP VSCode 中使用断点?

问题描述 投票:0回答:2
  1. c:\xampp
    中安装XAMPP v3.2.4 x64并设置环境变量路径

  1. 获取
    phpinfo()
    中的所有文本并按照https://xdebug.org/wizard下载dll文件并复制到
    c:\xampp\php\ext
    并在
    zend_extension=path
    末尾添加文本
    php.ini
    并检查
    phpinfo()
    页面和 xdebug 添加到此

  1. 添加
    [XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1
    在 php.ini 中

  1. 安装 VSCode v1.52.1

  1. 安装 Php 调试 v1.13.1

  1. htdocs
    测试名称中创建项目并在
    test.php
  2. 中创建文件

  1. 输入文本到

    test.php
    并在行中设置断点

  2. 为 PHP 创建自动

    launch.json

  1. 开始调试

  2. 启动 chrome 和 url:

    localhost/test/test.php

但是当刷新页面断点不起作用并且不停止代码时。

php visual-studio-code xdebug
2个回答
0
投票

只需检查监听端口即可

[XDebug]
zend_extension=C:\xampp\php\ext\php_xdebug-3.0.1-7.2-vc15-x86_64.dll
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.mode=debug
xdebug.idekey=VSCODE
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9000

0
投票

我遇到了这个问题,最终通过以下步骤解决了。

  1. 首先检查 VSCode 是否能够通过 log=true

    接收 Xdebug 消息
  2. 第二个也是最重要的一个与pathMappings相关,它将远程代码映射到本地代码
    听到的是我的 VSCode 调试配置

        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9001,
        "log": true,
        "pathMappings": { "/var/www/html": "${workspaceRoot}"
    
  3. 最后配置你的xdebug.ini(你也可以把它们放在php.ini中)

     zend_extension=zend_extension=C:\xampp\php\ext\php_xdebug-3.0.1-7.2-vc15-x86_64.dll 
     xdebug.remote_enable=1
     xdebug.remote_autostart=1
     xdebug.remote_port=9001
     # Very Import !! remote_connect_back should be turned off
     xdebug.remote_connect_back= 0
     xdebug.remote_host=172.17.0.X
     xdebug.remote_log=/tmp/xdebug.log
    

(这些配置与xdebug 2.9.X相关)

© www.soinside.com 2019 - 2024. All rights reserved.