skeeks / yii2-xml-request-parser
Yii2 xml 请求解析器
1.0.0
2015-07-12 16:41 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-08-29 03:29:37 UTC
README
Yii2 官方只发布了 JsonRequestParser,但没有 XmlRequestParser,因此创建了这样一个库。
安装
将 "bobchengbin/yii2-xml-request-parser": "*"
添加到 composer.json 的 require 部分
$ composer update
或者
$ composer require bobchengbin/yii2-xml-request-parser '*'
使用方法
# file app/config/main.php <?php return [ 'components' => [ 'request' => [ 'parsers' => [ 'text/xml' => 'bobchengbin\Yii2XmlRequestParser\XmlRequestParser', 'application/xml' => 'bobchengbin\Yii2XmlRequestParser\XmlRequestParser', ], ], ], ];
最终测试
然后你可以通过 Postman 等工具向你的应用发送一个 XML 请求,然后在应用中直接通过 Yii::$app->request->post()
获取数据。