vaneves / json-request-service-provider
Silex provider for request JSON
v1.0.1
2015-09-22 18:52 UTC
Requires
- silex/silex: ~1.1
This package is auto-updated.
Last update: 2024-12-19 10:14:11 UTC
README
Installing
Via Composer
composer require vaneves/json-request-service-provider
Usage
use Silex\Application; use Symfony\Component\HttpFoundation\Request; use Vaneves\Provider\JsonRequestServiceProvider; $app = new Application(); $app->register(new JsonRequestServiceProvider()); $app->post('/blog/posts', function (Request $request) use ($app) { $post = array( 'title' => $request->request->get('title'), 'body' => $request->request->get('body'), ); $post['id'] = createPost($post); return $app->json($post, 201); }); $app->run();