Skip to content

Instantly share code, notes, and snippets.

@vaneves
Last active September 24, 2015 11:48
Show Gist options
  • Save vaneves/6e4c039a439d09b1efd3 to your computer and use it in GitHub Desktop.
Save vaneves/6e4c039a439d09b1efd3 to your computer and use it in GitHub Desktop.
Curso Ninja - API / GET
<?php
$app->get('/posts', function () use ($app) {
$em = $app['orm.em'];
$results = $em->getRepository('App\Entities\Post')->findAll();
$hydrator = new CollectionExtractor(new DoctrineHydrator($em));
return $app->json($hydrator->extract($results));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment