orchestra/parser is a Laravel package for xml document parser for laravel and php.
It currently has 459 GitHub stars and 1.761.955 downloads on Packagist (latest version v10.0.0).
Install it with composer require orchestra/parser.
Discover more Laravel packages by orchestra
or browse all Laravel packages to compare alternatives.
Last updated
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>[email protected]</email>
</user>
</api>
to
$user = [
'id' => '1',
'email' => '[email protected]',
'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'],
]);
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
To install through composer, run the following command from terminal:
composer require "orchestra/parser"
Next add the service provider in config/app.php.
'providers' => [
// ...
Orchestra\Parser\XmlServiceProvider::class,
],
You might want to add Orchestra\Parser\Xml\Facade to class aliases in config/app.php:
'aliases' => [
// ...
'XmlParser' => Orchestra\Parser\Xml\Facade::class,
],