Skip to content

Instantly share code, notes, and snippets.

@vaneves
Created September 23, 2015 20:14
Show Gist options
  • Save vaneves/536bdef593c6af1e8e26 to your computer and use it in GitHub Desktop.
Save vaneves/536bdef593c6af1e8e26 to your computer and use it in GitHub Desktop.
Curso Ninja - API GET
<?php
$app->get('/posts/{id}', function ($id) use ($app) {
$em = $app['orm.em'];
$post = $em->getRepository('App\Entities\Post')->find($id);
$hydrator = new DoctrineHydrator($em);
return $app->json($hydrator->extract($post));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment