nyatmeat/xml-string-streamer-guzzle

Stream provider for Guzzle for use with xml-string-streamer for guzzle 6

1.1 2020-10-02 07:24 UTC

This package is auto-updated.

Last update: 2024-04-29 04:46:45 UTC


README

Use with xml-string-streamer

What is it?

Streams large XML files with low memory consumption, over HTTP using Guzzle.

Installing

Run composer require nyatmeat/xml-string-streamer-guzzle to install this package.

Examples

use Prewk\XmlStringStreamer;
use Prewk\XmlStringStreamer\Stream;
use Prewk\XmlStringStreamer\Parser;

$url = "http://example.com/really-large-xml-file.xml";

$CHUNK_SIZE = 1024;
$stream = Guzzle::createForFile($url, $CHUNK_SIZE);
or for stream interface 
$stream = Guzzle::createForPsrStream($psrStream, $CHUNK_SIZE);
$parser = new Parser\StringWalker();

$streamer = new XmlStringStreamer($parser, $stream);

while ($node = $streamer->getNode()) {
	// ...
}

For more info, see the xml-string-streamer repo.

Compatibility

  • For PHP >= 5.5 with Guzzle 6 compatibility, use version 0.4.0
  • For PHP >= 7.2 with Guzzle 7 compatibility, use latest (1.0.0 and onwards)