Skip to content

Instantly share code, notes, and snippets.

@ryanellis
Last active January 19, 2017 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanellis/b76658c2974ef63e99066db8c94cfaa6 to your computer and use it in GitHub Desktop.
Save ryanellis/b76658c2974ef63e99066db8c94cfaa6 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\HttpFoundation\Response;
/* INSIDE THE CONTROLLER */
// the varaibles you want to dump out
$var1 = 'bar_1;
$var2 = 'bar_2;
// create the twig template
$template = $this->get('twig')->createTemplate('{{ dump(foo) }} {{ dump(foo2) }}');
// render the template
$res = $template->render(['foo'=>$va1, 'foo2'=>$var2]);
// return a simple response and set the content with the rendered Twig template
$response = new Response();
$response->setContent($_res);
$response->setStatusCode(Response::HTTP_OK);
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment