Skip to content

Instantly share code, notes, and snippets.

@micronax
Last active December 6, 2020 19:06
Show Gist options
  • Save micronax/5747649 to your computer and use it in GitHub Desktop.
Save micronax/5747649 to your computer and use it in GitHub Desktop.
Render XML-Data using Twig-Template within the SILEX-Microframework
<?php
// Add to use-statements
use Symfony\Component\HttpFoundation\Response;
// [...] Your application code
// Action to return XML from Twig-Template
$app->get(
'/sitemap.xml',
function () use ($app) {
$data = array();
return new Response($app['twig']->render(
'sitemap.xml.twig', // Your twig-template eg. sitemap.xml.twig
array('data' => $data)
),
200,
array('Content-Type' => 'application/xml')
);
}
);
@JakubBadowski
Copy link

Thx a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment