https://github.com/vaneves/json-request-service-provider
https://github.com/vaneves/json-request-service-provider
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vaneves/json-request-service-provider
- Owner: vaneves
- License: unlicense
- Created: 2015-09-22T17:59:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-22T18:54:38.000Z (over 10 years ago)
- Last Synced: 2025-09-22T05:23:45.851Z (9 months ago)
- Language: PHP
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JsonRequestServiceProvider
## Installing
Via Composer
```
composer require vaneves/json-request-service-provider
```
## Usage
``` php
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();
```