Hi all
I want to implement a web service with Symfony 2 using REST and Json, but i diden't find doccumentation about that
please can anyone help me to do that.
thx for all
Moderators: dcobalt, tiagojsag
/**
* @Route("/rest", requirements={"_method" = "GET"})
*/
public function getAction()
{
return new Response('<form method="post" action="/rest"><input type="submit" value="Click" /></form>');
}
/**
* @Route("/rest", requirements={"_method" = "POST"})
*/
public function postAction()
{
return new Response('POST');
}$response = new Response(json_encode($myArray));
$response->headers->set('Content-Type', 'application/json'); /**
* @Route("/rest", requirements={"_method" = "GET"}, defaults={"_format" = "json"})
*/
public function showAction()
{
$data = /* ... */;
return new Response(json_encode($data));
}Return to General Symfony 2 discussion
Users browsing this forum: No registered users and 2 guests