orchestra / parser
XML Document Parser for Laravel and PHP
Fund package maintenance!
Liberapay
paypal.me/crynobone
Installs: 535 419
Dependents: 7
Suggesters: 0
Security: 0
Stars: 345
Watchers: 19
Forks: 39
Open Issues: 6
Requires
- php: >=7.3
- illuminate/container: ^8.0
- laravie/parser: ^2.1.2
Requires (Dev)
- orchestra/testbench: ^6.0
This package is auto-updated.
Last update: 2020-12-27 01:10:14 UTC
README
Parser Component is a framework agnostic package that provide a simple way to parse XML to array without having to write a complex logic.
Imagine if you can parse
<api> <user followers="5"> <id>1</id> <email>crynobone@gmail.com</email> </user> </api>
to
$user = [ 'id' => '1', 'email' => 'crynobone@gmail.com', 'followers' => '5' ];
by just writing this:
use Orchestra\Parser\Xml\Facade as XmlParser; $xml = XmlParser::load('path/to/above.xml'); $user = $xml->parse([ 'id' => ['uses' => 'user.id'], 'email' => ['uses' => 'user.email'], 'followers' => ['uses' => 'user::followers'], ]);
Table of Content
Version Compatibility
Laravel | Parser |
---|---|
5.5.x | 3.5.x |
5.6.x | 3.6.x |
5.7.x | 3.7.x |
5.8.x | 3.8.x |
6.x | 4.x |
7.x | 5.x |
8.x | 6.x |
Installation
To install through composer, run the following command from terminal:
composer require "orchestra/parser"
Configuration
Next add the service provider in config/app.php
.
'providers' => [ // ... Orchestra\Parser\XmlServiceProvider::class, ],
Aliases
You might want to add Orchestra\Parser\Xml\Facade
to class aliases in config/app.php
:
'aliases' => [ // ... 'XmlParser' => Orchestra\Parser\Xml\Facade::class, ],