Last active
October 20, 2015 14:44
-
-
Save vaneves/0635f0aae9c9b83b11ab to your computer and use it in GitHub Desktop.
Curso Ninja - API / POST
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->post('/posts', function (Request $request) use ($app) { | |
$post = new Post(); | |
$post->setTitle($request->get('title')); | |
$post->setContent($request->get('content')); | |
$em = $app['orm.em']; | |
$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