gowork / symfony-json-request
Symfony Json Request
Installs: 18 094
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.0
- symfony/framework-bundle: ^4.3||^5.0||^6.0
- thecodingmachine/safe: ^2.2
Requires (Dev)
- phpstan/phpstan: ^1.7
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- symfony/yaml: ^4.3||^5.0
- vimeo/psalm: ^4.3
This package is auto-updated.
Last update: 2024-11-11 20:21:44 UTC
README
Converts json request body to request array.
Install
composer require gowork/symfony-json-request
Setup bundle
<?php public function registerBundles(): array { $bundles = [ // ... new GW\SymfonyJsonRequest\SymfonyJsonRequestBundle(), ]; ... }
Usage
When sending request with json body and application/json
content type, this bundle converts json keys to symfony request keys:
<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; public function controllerAction(Request $request): Response { $content = (string)$request->request->get('content'); }
curl 'controller/path' \ -H 'Accept: application/json, text/plain, */*' \ -H 'Content-Type: application/json;charset=UTF-8' \ --data-binary '{"content"s:"test","nick":"test"}'