I'm getting back into the PHP game after... a long time. I'm looking at Twig, and need to see more of what's going on. I've found some text that needs to go into my config.yml file. Caveat: it's not on my system. Does it come w/ the Twig release or do I have to install Symfony as well? Kind of lost here.
Cheers.
EDIT: I just need {{ dump(var) }} to work. httpd error log tells me the: PHP Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "dump" does not exist in
I'm setting my Twig environment like so:
$twig = new Twig_Environment( $loader, array(
'cache' => '/tmp',
'debug' => true
));
You need to make sure that you are using twig version 1.5 or later. It looks like you are only missing 1 piece adding the debug extension to your twig environment.
$twig->addExtension(new Twig_Extension_Debug());
Here is the documentation for the dump function:
http://twig.sensiolabs.org/doc/functions/dump.html
The dump function is not available by default. You must add the Twig_Extension_Debug extension explicitly when creating your Twig environment:
$twig = new Twig_Environment($loader, array(
'debug' => true,
// ...
));
$twig->addExtension(new Twig_Extension_Debug());
Even when enabled, the dump function won't display anything if the debug option on the environment is not enabled (to avoid leaking debug information on a production server).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With