rcsofttech/console-profiler-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rcsofttech/console-profiler-bundle

Composer 安装命令:

composer require rcsofttech/console-profiler-bundle

包简介

A live, non-blocking TUI profiler dashboard for Symfony console commands. Displays real-time memory, duration, and SQL query metrics.

README 文档

README

CI Version Codacy Badge Codacy Badge

If you've ever watched a long-running Symfony console command crawl and wondered, "Is this thing leaking memory? Am I hammering the database with N+1 queries right now?" — this bundle is for you.

The standard Symfony Profiler is amazing for HTTP requests, but it doesn't help you much when a queue worker is eating up RAM in the background. The Console Profiler Bundle hooks right into your terminal to give you a live, premium TUI dashboard while your commands are actually running.

Console Profiler Dashboard

Features

  • Live, auto-refreshing TUI dashboard pinned to the top of your terminal
  • Memory usage, peak memory, and growth rate with color-coded bars
  • Real-time trend indicators ( ) for memory and SQL
  • CPU user/system time tracking via getrusage()
  • Automatic SQL query counting via Doctrine DBAL 4 Middleware
  • JSON profile export for CI pipeline regression testing
  • Exit code stamping on command completion
  • Zero configuration required — works out of the box
  • Graceful degradation without ext-pcntl (no auto-refresh)

Installation

Pop it into your dev dependencies via Composer:

composer require --dev rcsofttech/console-profiler-bundle

Note: You'll need PHP 8.4+, Symfony 8.0+, and the ext-pcntl extension (which you probably already have on Mac/Linux) to get the smooth async UI updates.

Configuration (Optional)

You don't have to configure anything, it works right out of the box. But if you want to tweak things, create config/packages/console_profiler.yaml:

console_profiler:
    # Disable the profiler entirely if you want
    enabled: true

    # It's smart enough to turn itself off when kernel.debug is false
    exclude_in_prod: true

    # How often the TUI updates (in seconds)
    refresh_interval: 1

    # Don't bother profiling these noisy default commands
    # (these four are the defaults — add your own as needed)
    excluded_commands:
        - 'list'
        - 'help'
        - 'completion'
        - '_complete'

    # Set this to a path to save a JSON dump for CI regression testing
    profile_dump_path: '%kernel.project_dir%/var/log/profiler/last_run.json'

Practical Examples

1. Debugging a leaky queue worker

Run your worker normally:

bin/console messenger:consume async

Look at the Memory row in the profiler. You'll see a +X MB/s indicator showing exactly how fast memory is growing. If it holds steady into the yellow or red, you know you've got a leak to fix.

2. Guarding against N+1 queries in CI

Set your profile_dump_path in console_profiler.yaml. Then, in your CI run:

# Run your heavy sync command
bin/console app:nightly-sync

# Check if someone blew up the query count using jq
SQL_COUNT=$(jq '.counters.sql_queries' var/log/profiler/last_run.json)

if [ "$SQL_COUNT" -gt 500 ]; then
  echo "Whoops! Regression: SQL queries exceeded 500 (got $SQL_COUNT)"
  exit 1
fi

The JSON dump tracks memory, CPU times, SQL counts, and more.

JSON Profile Schema

When profile_dump_path is configured, the following JSON is written on command completion:

{
  "timestamp": "2024-01-15T10:30:00+00:00",
  "command": "app:import-data",
  "environment": "dev",
  "exit_code": 0,
  "duration_seconds": 12.4523,
  "memory": {
    "usage_bytes": 16777216,
    "peak_bytes": 33554432,
    "limit_bytes": 268435456,
    "growth_rate_bytes_per_sec": 524288.0
  },
  "cpu": {
    "user_seconds": 8.12,
    "system_seconds": 0.34
  },
  "counters": {
    "sql_queries": 142,
    "loaded_classes": 312,
    "declared_functions": 1204,
    "included_files": 89,
    "gc_cycles": 2
  },
  "system": {
    "php_version": "8.4.12",
    "sapi": "cli",
    "pid": 12345,
    "opcache_enabled": true,
    "xdebug_enabled": false
  }
}

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Ensure tests pass: vendor/bin/phpunit
  4. Ensure static analysis passes: vendor/bin/phpstan analyze
  5. Submit a pull request

License

MIT License.

rcsofttech/console-profiler-bundle 适用场景与选型建议

rcsofttech/console-profiler-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 16, 最近一次更新时间为 2026 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「console」 「profiler」 「middleware」 「dashboard」 「tui」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rcsofttech/console-profiler-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rcsofttech/console-profiler-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 rcsofttech/console-profiler-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-25