Created
September 23, 2015 20:14
-
-
Save vaneves/536bdef593c6af1e8e26 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/{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