YML (Yandex XML format) parser for Laravel

v1.2.0 2018-10-03 12:42 UTC

This package is not auto-updated.

Last update: 2022-05-13 04:16:05 UTC


Parser for yml( files adapted for Laravel 5.5+.

Forked from

Thanks for Serkin Alexander!

YMLParser out of box have two drivers for different file sizes:

  • XMLReader - for medium and large xml files
  • SimpleXML - for small xml files

Laravel YML parsing notice:

On current step Laravel is not required, but development of this package is going inside Laravel project.


Package requires php-xmlrpc and php-mbstring

sudo apt-get install php-xmlrpc php-mbstring

Require package via Composer:

composer require larafull/ymlparser:dev-master


Remote YML parsing in Laravel etc

Since v1.2 remote parsing is available:

use YMLParser\YMLParser;
use YMLParser\Driver\XMLReader;

$url = 'https://somedomain/somefolder/somefile.yml.xml';

$parser = new YMLParser(new XMLReader);


$offers = $parsers->getOffers(); // etc

Getting all offers from file

use YMLParser\YMLParser;
use YMLParser\Driver\XMLReader;

$filename = '/path/to/file/file.xml';

//   User XMLReader driver large xml files or SimpleXML driver for small xml files.

$parser = new YMLParser(new XMLReader);
$parser->open($filename); // throws \Exception if $filename doesn't exist or empty
foreach($parser->getOffers() as $offer): // YMLParser::getOffers() returns \Generator
    echo $offer['url'];

Using filters for offers:

YMLParser::getOffers() can take filter function as an argument. Filter should be an anonymous function which returns true or false

use YMLParser\YMLParser;
use YMLParser\Driver\SimpleXML;

$filename = '/path/to/file/file.xml';

$parser = new YMLParser(new SimpleXML);

// Anonnymous filter function example:

$filter = function($element) {
    return !empty($element['url']);

$offers = iterator_to_array($parser->getOffers($filter));

// Let's dump first offer via Laravel dump():



  • PHP: >= 7.1
  • xmlrpc extension
  • mbstring extension

Modifications after fork

DriverInterface can be changed. For capability check static variables will be added.

Migrations to create models from YML will be available later.

Contribution and your ideas

Create pull requests or/and message me here:

Telegram: @vvmspace

Twitter: @vvmspace