Last active
September 24, 2015 11:48
-
-
Save vaneves/6e4c039a439d09b1efd3 to your computer and use it in GitHub Desktop.
Curso Ninja - API / GET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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