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

本文详细介绍了如何配置 XDebug 进行 PHP 代码调试,包括设置远程调试、性能分析及内存消耗监控。通过修改 php.ini 文件,启用 XDebug 的远程调试功能,并在 Visual Studio Code 中设置相应的调试配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

修改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
        }
    ]
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值