sabre-io / xml

sabre/xml is an XML library that you may not hate.
http://sabre.io/xml/
BSD 3-Clause "New" or "Revised" License
516 stars 77 forks source link

Allowed memory size exhausted when writing #186

Closed david-kristin closed 4 years ago

david-kristin commented 4 years ago

I use the Service for writing XML, it look like this:

$this->service->write('rss', [ 'channel' => $channel, ])

The channel is composed of thousands of items, thus I am getting Allowed memory size of 134217728 bytes exhausted (tried to allocate 171570808 bytes) that is related to $w->outputMemory() line.

How can this be solved? Generally, the problem is writing a huge text.

evert commented 4 years ago

The services work with the XMLWriter to output a string by default. If you skip the Service class and work with Writer directly, you can use openURI on the writer instead to write directly to a stream.

This method should take php://output as an argument I believe.

david-kristin commented 4 years ago

Thank you so much, evert. Otherwise I would be stuck on this one much longer.