nowo-tech/console-debug-bundle
Composer 安装命令:
composer require nowo-tech/console-debug-bundle
包简介
Symfony bundle that mirrors cdbg() calls to the browser console for authorized users, even in production.
README 文档
README
⭐ Found this useful? Install from Packagist · Give it a star on GitHub so more developers can find it.
Console Debug Bundle — Production-safe browser console debugging with cdbg(), similar in spirit to Symfony's dd() but non-blocking: it collects file, line, and variable data server-side and injects a <script> that prints grouped console.log() output for authorized users only. Tested on Symfony 7.4, 8.0, and 8.1 (also compatible with Symfony 6.x and 7.0–7.3) · PHP 8.1+ (Symfony 8.x requires PHP 8.4+).
Features
cdbg()helper — Drop-in debug calls anywhere in PHP; execution continues (no dump-and-die).- Role-gated — Only authenticated users with configured roles see output, even in production.
- Rich context — Captures caller file, line, optional label, and normalized variable payloads.
- HTML injection — Appends a JSON payload and runner script before
</body>on HTML responses. - Custom gate service — Replace or extend authorization with route/query-param logic.
Installation
composer require nowo-tech/console-debug-bundle
With Symfony Flex, the recipe registers the bundle and adds config. Without Flex, see docs/INSTALLATION.md.
Manual registration in config/bundles.php:
return [ // ... Nowo\ConsoleDebugBundle\NowoConsoleDebugBundle::class => ['all' => true], ];
Grant a debug role to trusted users:
security: role_hierarchy: ROLE_CONSOLE_DEBUG: ROLE_USER
Configuration
nowo_console_debug: enabled: true roles: - ROLE_CONSOLE_DEBUG console_method: log label_prefix: '[cdbg]' shorten_paths: true query_param: console_debug # gate_service: App\ConsoleDebug\AppConsoleDebugGate
Usage
use function Nowo\ConsoleDebugBundle\cdbg; public function show(Request $request): Response { cdbg('items snapshot', $items, $request->query->all()); return $this->render('page.html.twig', ['items' => $items]); }
Open DevTools → Console on the rendered HTML page. Each cdbg() call appears as an expanded group with file, line, and values.
Twig (requires twig/twig)
Same behaviour as Symfony's native dump, but output goes to the browser console:
{# full Twig context (macros/templates excluded), like {% dump %} #} {% cdbg %} {# one or more variables, like {{ dump(user) }} #} {{ cdbg(user) }} {% cdbg user, items %}
When called empty, the label is twig context and the template name/line is used as the source location.
Documentation
- Installation
- Configuration
- Usage
- Performance
- Contributing
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
Additional documentation
Requirements
- PHP
>=8.1(<8.6); Symfony 8.0 and 8.1 require PHP 8.4+ - Symfony 7.4, 8.0, or 8.1 (minimum supported minors; also works on Symfony 6.x and 7.0–7.3 via
composer.jsonconstraints) symfony/security-bundle(or equivalent) in your application for role-based gates
Development
make up
make install
make test
make cs-check
make phpstan
make release-check
Demo
demo/symfony7— Symfony 7.4, host port 8010 by default (PORTin.env)demo/symfony8— Symfony 8.1 (PHP 8.4+), host port 8011 by default
Each demo runs FrankenPHP + Caddy in Docker. Login as debugger / debug and visit /debug to see cdbg() in the browser console. See docs/DEMO-FRANKENPHP.md.
Global demo commands: make -C demo help (e.g. make -C demo up-symfony8).
Tests and coverage
- Tests: PHPUnit (PHP)
- PHP: 100%
License and author
MIT · Nowo.tech · Héctor Franco Aceituno
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-09