Twig extension for dumping a variable to the browser console.
- PHP >= 7.1
- Twig >= 2.4
$ composer require michaelhall/twig-console-dump
After enabling this extension, the dump()
function can be used to dump a variable to the browser console.
Internally, this is done via inline JavaScript using console.log()
functions.
The variable is only dumped to the console if debug mode is enabled in Twig, otherwise nothing is outputted.
{{ dump(foo) }}
{{ dump(foo, 'Bar') }}
{{ dump(foo, 'Bar', {'script-nonce': 'baz'}) }}
- script-nonce: The
nonce
attribute to use in the inline<script>
tag for CSP-protection.
MIT