Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrplenik/1545031 to your computer and use it in GitHub Desktop.
Save piotrplenik/1545031 to your computer and use it in GitHub Desktop.
Playing with the Symfony2 serializer
<?php
// Inside your action
$this->serializer = new \Symfony\Component\Serializer\Serializer();
$this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
$this->serializer->setEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());
return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment