GithubHelp home page GithubHelp logo

yii2-xmlparser's Introduction

Build Status version Download Issues

Overview

This is a library help you to handle the xml request. As we all know, Yii2 provided an built-in request parser for json like requests, it's yii\web\JsonParser. Sometimes, we need to handle the request of xml, so this library is birthed.

Install

Add light/yii2-xmlparser to composer.json, you can assign version as *:

$ composer install
//or run
$ composer update

also we can do like this:

$ composer require light/yii2-xmlparser=* --prefer-dist

Usage

# file app/config/main.php [your configuration file]
<?php

return [
    'components' => [
    'request' => [
        'parsers' => [
	        	'text/xml' => 'light\yii2\XmlParser',
	            'application/xml' => 'light\yii2\XmlParser',
	        ],
        ],
    ],
];

Test

$ phpunit

LICENSE

MIT

yii2-xmlparser's People

Contributors

danielmartinus avatar lichunqiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yii2-xmlparser's Issues

Indexed Arrays after parsing

Hi,
I want to use your parser but I have a problem.

I send via POST the following:

 <orders>
      <order id="58382388">
      <item id="6" count="1" />
     </order>
         <order id="58382386">
      <item id="8" count="1" />
  </order>
</orders>

Your parser then returns an indexed array which I can access like this: $arrays['order'][0]['item'].
But if I send only one order I get an non indexed array: $arrays['order']['item']

 <orders>
      <order id="58382388">
      <item id="6" count="1" />
     </order>
</orders>

From my point of view this makes it more complex, unnecessarily. Classic SimpleXML Parser delivers always indexed arrays. Much easier to work with...

Not PHP 7.2 compatible

You need to update "Object" to "BaseObject". "Object" is a PHP reserved word enforced by PHP 7.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.