skeeks/yii2-xml-request-parser

Yii2 xml 请求解析器

安装: 26

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 2

分支: 4

类型:yii2-extension

1.0.0 2015-07-12 16:41 UTC

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() 获取数据。