Skip to content

6dreams/stream-reader

Repository files navigation

StreamReader Collection

PHP XML Stream Reader

Reads XML from either a string or a stream, allowing the registration of callbacks when an elemnt is found that matches path.

Installation

  • Install Zephir
  • zephir build
  • Add extension=streamparser to your php.ini

Usage Example

<?php
declare(strict_types = 1);

$handle = \fopen(__DIR__ . 'games.xml', 'rb');

(new SixDreams\StreamReader\XmlStreamReader())
    ->registerCallback('/root/sport', '/root/sport/groups/group/events/event', function (string $rawXml) {
        echo 'XML: ' . $rawXml . "\n";
    })
    ->parse($handle);

\fclose($handle);

PHP JSON Stream Reader

@todo...