orchestra / parser
XML Document Parser for Laravel and PHP
Fund package maintenance!
Liberapay
paypal.me/crynobone
Requires
- php: ^8.2
- illuminate/container: ^12.0
- laravie/parser: ^3.0
Requires (Dev)
- laravel/pint: ^1.21
- orchestra/testbench: ^10.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.5
- 10.x-dev
- v10.0.0
- 9.x-dev
- v9.0.0
- 8.x-dev
- v8.0.0
- 7.x-dev
- v7.0.1
- v7.0.0
- 6.x-dev
- v6.1.0
- v6.0.0
- 5.x-dev
- v5.0.0
- 4.x-dev
- v4.0.0
- 3.8.x-dev
- v3.8.0
- 3.7.x-dev
- v3.7.0
- 3.6.x-dev
- v3.6.0
- 3.5.x-dev
- v3.5.0
- 3.4.x-dev
- v3.4.0
- 3.3.x-dev
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.2.0
- v2.1.0
This package is auto-updated.
Last update: 2025-03-01 01:14:12 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'], ]);
Version Compatibility
Laravel | Parser |
---|---|
6.x | 4.x |
7.x | 5.x |
8.x | 6.x |
9.x | 7.x |
10.x | 8.x |
11.x | 9.x |
12.x | 10.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, ],