Last active
December 6, 2020 19:06
-
-
Save micronax/5747649 to your computer and use it in GitHub Desktop.
Render XML-Data using Twig-Template within the SILEX-Microframework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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') | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx a lot :)