XDeBug vscode断点以及性能分析配置应用

34 篇文章 1 订阅

修改php配置 并重启服务

v3.*

[XDebug]
xdebug.output_dir="/mnt/c/Users/Administrator/Desktop/xdebug"
xdebug.mode = debug
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9002
xdebug.start_with_request = yes

v2.*

[Xdebug]
zend_extension=F:/phpstudy_pro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll
#0 1 2 3 4#调试详细显示
xdebug.collect_params=2
xdebug.collect_return=1
#xdebug.auto_trace=On
#xdebug.trace_output_dir=F:/phpstudy_pro/Extensions/php_log/php7.3.4nts.xdebug.trace

;性能分析开关
xdebug.profiler_enable=On
xdebug.profiler_output_dir=Z:/tmp

;远程调试是否开启
xdebug.remote_enable=On
xdebug.remote_host=localhost
xdebug.remote_port=9002
xdebug.remote_handler=dbgp

;vscode靠这个配置断点 开启关闭
xdebug.remote_autostart=1

;自定义名称
xdebug.profiler_output_name = "cachegrind.out.%s"

xdebug.collect_includes=1


[Xdebug]
xdebug.remote_enable=On
xdebug.remote_autostart=1
xdebug.collect_params=2
xdebug.collect_includes=1
xdebug.remote_port=9002



[Xdebug]
;2021年2月21日 04:26:02 最新配置
xdebug.remote_enable=On
xdebug.remote_autostart=1
xdebug.collect_params=2
xdebug.collect_includes=1
xdebug.collect_vars=1
xdebug.remote_port=9002

;自动记录瓶颈XDEBUG_PROFILE
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir = "/www/wwwlogs/debug/profiler"
xdebug.profiler_output_name = cachegrind.out.%u

;自动记录内存消耗XDEBUG_TRACE
xdebug.auto_trace=0
xdebug.trace_enable_trigger=1
xdebug.trace_format=2
xdebug.show_mem_delta=1
xdebug.trace_output_name = trace.out.%u.html
xdebug.trace_output_dir = "/mnt/c/Users/Administrator/Desktop"

xdebug.var_display_max_children=512
xdebug.var_display_max_data=512
xdebug.var_display_max_depth=15

在vscode里安装插件

添加配置

设置端口9002 跟之前配置一样

性能分析安装

https://github.com/jokkedk/webgrind

下载源码

webgrind\config.php

修改

    static $storageDir = 'Z:/tmp';

    static $profilerDir = 'tmp';

进入webgrind

完成

最后加上linux与win的vscode配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Linux_XDebug",
            "type": "php",
            "request": "launch",

            // "stopOnEntry":false,
            "localSourceRoot": "${workspaceRoot}",
            "serverSourceRoot": "/mnt/d/word",
            "port": 9002
        },
        {
            "name": "Windows_XDebug",
            "type": "php",
            "request": "launch",
            // "program": "${file}",
            // "cwd": "${fileDirname}",
            // "localSourceRoot": "${workspaceRoot}",
            // "serverSourceRoot": "/mnt/d/word",
            "port": 9002
        }
    ]
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 VS Code 中配置 Xdebug,请按照以下步骤操作: 1. 安装 PHP Debug 扩展程序 在 VS Code 中,按下 F1 打开命令面板,输入“Extensions: Install Extensions”,选择 PHP Debug 并安装。 2. 配置 PHP Debug 扩展程序 在 VS Code 中,按下 F1 打开命令面板,输入“Preferences: Open User Settings”,找到“php”并单击“Edit in settings.json”。在打开的 JSON 文件中,添加以下代码: ``` "php.validate.enable": true, "php.validate.run": "onSave", "php.validate.executablePath": "/path/to/php", "php.validate.showErrors": "on", "php.debug.enable": true, "php.debug.port": 9000, "php.debug.ideKey": "VSCode", "php.debug.pathMappings": { "/path/to/project": "${workspaceFolder}" } ``` - `"php.validate.enable": true`: 启用 PHP 语法验证。 - `"php.validate.run": "onSave"`: 在保存文件时验证 PHP 语法。 - `"php.validate.executablePath": "/path/to/php"`: 指定 PHP 可执行文件的路径。 - `"php.validate.showErrors": "on"`: 显示 PHP 错误和警告。 - `"php.debug.enable": true`: 启用调试。 - `"php.debug.port": 9000`: 指定调试器监听的端口。 - `"php.debug.ideKey": "VSCode"`: 指定 IDE 密钥。 - `"php.debug.pathMappings": {...}`: 指定项目路径和本地路径的映射。例如,如果项目位于 `/path/to/project`,则映射为 `${workspaceFolder}`。 3. 配置 XdebugPHP 配置文件中,添加以下代码: ``` [xdebug] zend_extension="/path/to/xdebug.so" xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.remote_port=9000 xdebug.remote_host="localhost" ``` - `zend_extension="/path/to/xdebug.so"`: 指定 Xdebug 扩展程序的路径。 - `xdebug.remote_enable=1`: 启用远程调试。 - `xdebug.remote_autostart=1`: 自动启动远程调试。 - `xdebug.remote_port=9000`: 指定调试器监听的端口。 - `xdebug.remote_host="localhost"`: 指定调试器的主机名。 4. 开始调试 在 VS Code 中,打开要调试的 PHP 文件,并设置断点。然后,按下 F5 启动调试。如果一切正常,调试器应该连接到 PHP 进程并停在您设置的断点处。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值