symfony-bundles / json-request-bundle
Symfony JsonRequest Bundle
Installs: 1 229 120
Dependents: 5
Suggesters: 0
Security: 0
Stars: 49
Watchers: 5
Forks: 24
Open Issues: 3
Type:symfony-bundle
Requires
- php: >=7.4 || ^8.0
- ext-json: *
- symfony/framework-bundle: ^4.3 || ^5.0 || ^6.0
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/php-code-coverage: ^9.2
- phpunit/phpunit: ^9.5
- symfony/browser-kit: ^5.2 || ^6.0
- symfony/yaml: ^5.2 || ^6.0
README
Installation
- Require the bundle with composer:
composer req symfony-bundles/json-request-bundle
What is JsonRequest Bundle?
This bundle will help you to work with json requests as standard requests without using «crutches». If previously for
fetching of data from the request you did like this:
$data = json_decode($request->getContent())
, it is now in this already there is no need to.
For example when sending json-request from AngularJS, Vue.js or etc. Early:
public function indexAction(Request $request) { $data = json_decode($request->getContent(), true); // uses request data $name = isset($data['name']) ? $data['name'] : null; }
Now you can work with json-request as with standard request:
public function indexAction(Request $request) { $name = $request->get('name'); }
Per default request content will be transformed only for requests with content type json
or jsonld
.
but you can stil configure it with
# serices.yaml json_request: content_types: - json - jsonld - someouthertype