⭐ 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+).
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.
composer require nowo-tech/console-debug-bundleWith 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_USERnowo_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\AppConsoleDebugGateuse 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.
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.
- Installation
- Configuration
- Usage
- Performance
- Contributing
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
- 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
make up
make install
make test
make cs-check
make phpstan
make release-checkdemo/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: PHPUnit (PHP)
- PHP: 100%
MIT · Nowo.tech · Héctor Franco Aceituno