Skip to content

Instantly share code, notes, and snippets.

@mrsinguyen
Forked from micronax/index.php
Created August 30, 2017 00:45
Show Gist options
  • Select an option

  • Save mrsinguyen/bb8c2f7216efea036a9b05ed1f95edd0 to your computer and use it in GitHub Desktop.

Select an option

Save mrsinguyen/bb8c2f7216efea036a9b05ed1f95edd0 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')
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment