michaelhall / twig-console-dump
This package is abandoned and no longer maintained.
The author suggests using the nicedump/nicedump-twig package instead.
Twig extension for dumping a variable to browser console.
v1.0.0
2018-11-05 20:00 UTC
Requires
- php: >=7.1
- twig/twig: ^2.4
Requires (Dev)
- phpunit/phpunit: ^5.5||^6.0||^7.0
This package is auto-updated.
Last update: 2022-02-01 13:14:57 UTC
README
Twig extension for dumping a variable to the browser console.
Requirements
- PHP >= 7.1
- Twig >= 2.4
Install with composer
$ composer require michaelhall/twig-console-dump
Basic usage
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 a variable
{{ dump(foo) }}
Result
Dump a variable with a label
{{ dump(foo, 'Bar') }}
Result
Additional options
{{ dump(foo, 'Bar', {'script-nonce': 'baz'}) }}
- script-nonce: The
nonce
attribute to use in the inline<script>
tag for CSP-protection.
License
MIT