|
| 1 | +SymfonyBundles JsonRequest Bundle |
| 2 | +================================= |
| 3 | + |
| 4 | +[![SensioLabsInsight][sensiolabs-insight-image]][sensiolabs-insight-link] |
| 5 | + |
| 6 | +[![Build Status][testing-image]][testing-link] |
| 7 | +[![Scrutinizer Code Quality][scrutinizer-code-quality-image]][scrutinizer-code-quality-link] |
| 8 | +[![Code Coverage][code-coverage-image]][code-coverage-link] |
| 9 | +[![Total Downloads][downloads-image]][package-link] |
| 10 | +[![Latest Stable Version][stable-image]][package-link] |
| 11 | +[![License][license-image]][license-link] |
| 12 | + |
| 13 | +What is JsonRequest Bundle? |
| 14 | +--------------------------- |
| 15 | +This bundle will help you to work with json requests as standard requests without using «crutches». |
| 16 | +If previously for fetching of data from the request you did like this: |
| 17 | +`$data = json_decode($request->getContent())`, |
| 18 | +it is now in this already there is no need to. |
| 19 | + |
| 20 | +For example when sending json-request from AngularJS, Vue.js or etc. |
| 21 | +Early: |
| 22 | +``` php |
| 23 | +public function indexAction(Request $request) |
| 24 | +{ |
| 25 | + $data = json_decode($request->getContent(), true); |
| 26 | + |
| 27 | + // uses request data |
| 28 | + $name = isset($data['name']) ? $data['name'] : null; |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +Now you can work with json-request as with standard request: |
| 33 | +``` php |
| 34 | +public function indexAction(Request $request) |
| 35 | +{ |
| 36 | + $name = $request->get('name'); |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +Installation |
| 41 | +------------ |
| 42 | +* Require the bundle with composer: |
| 43 | + |
| 44 | +``` bash |
| 45 | +composer require symfony-bundles/json-request-bundle |
| 46 | +``` |
| 47 | + |
| 48 | +[package-link]: https://packagist.org/packages/symfony-bundles/json-request-bundle |
| 49 | +[license-link]: https://github.com/symfony-bundles/json-request-bundle/blob/master/LICENSE |
| 50 | +[license-image]: https://poser.pugx.org/symfony-bundles/json-request-bundle/license |
| 51 | +[testing-link]: https://travis-ci.org/symfony-bundles/json-request-bundle |
| 52 | +[testing-image]: https://travis-ci.org/symfony-bundles/json-request-bundle.svg?branch=master |
| 53 | +[stable-image]: https://poser.pugx.org/symfony-bundles/json-request-bundle/v/stable |
| 54 | +[downloads-image]: https://poser.pugx.org/symfony-bundles/json-request-bundle/downloads |
| 55 | +[sensiolabs-insight-link]: https://insight.sensiolabs.com/projects/dea68633-2368-4e12-a516-89157d2c6b07 |
| 56 | +[sensiolabs-insight-image]: https://insight.sensiolabs.com/projects/dea68633-2368-4e12-a516-89157d2c6b07/big.png |
| 57 | +[code-coverage-link]: https://scrutinizer-ci.com/g/symfony-bundles/json-request-bundle/?branch=master |
| 58 | +[code-coverage-image]: https://scrutinizer-ci.com/g/symfony-bundles/json-request-bundle/badges/coverage.png?b=master |
| 59 | +[scrutinizer-code-quality-link]: https://scrutinizer-ci.com/g/symfony-bundles/json-request-bundle/?branch=master |
| 60 | +[scrutinizer-code-quality-image]: https://scrutinizer-ci.com/g/symfony-bundles/json-request-bundle/badges/quality-score.png?b=master |
0 commit comments