Skip to content

Instantly share code, notes, and snippets.

@vaneves
Last active October 20, 2015 14:45
Show Gist options
  • Save vaneves/d6c2660b92446d410b08 to your computer and use it in GitHub Desktop.
Save vaneves/d6c2660b92446d410b08 to your computer and use it in GitHub Desktop.
Curso Ninja - API / PUT
<?php
$app->put('/posts/{id}', function ($id, Request $request) use ($app) {
$em = $app['orm.em'];
$post = $em->getRepository('App\Entities\Post')->find($id);
$post->setTitle($request->get('title'));
$post->setContent($request->get('content'));
$em->persist($post);
$em->flush();
return $app->json($hydrator->extract($post));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment