gowork/symfony-json-request
最新稳定版本:v0.3.0
Composer 安装命令:
composer require gowork/symfony-json-request
包简介
Symfony Json Request
README 文档
README
Converts json request body to request array.
Starting from Symfony 6.3 there is native $request->getPayload() method that can be used instead of this package
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"}'
统计信息
- 总下载量: 22.82k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-17