halilim/xml-iterator
halilim/xml-iterator offers a simple, memory-efficient way to iterate over XML in PHP. Built on XMLReader, it lets you loop through nodes with foreach and parse large XML files without loading them fully into memory—ideal for big feeds, exports, and streaming XML data.
XMLReader instead of loading a DOM, it makes "import a 500 MB supplier catalog / sitemap / product feed" a feasible roadmap item on standard PHP-FPM and queue-worker memory limits, rather than a special-infrastructure project.Adopt when:
memory_limit (multi-MB to GB), or arrives as a stream you can't buffer.<item> as an array" — and do not need XPath, namespaces, or schema validation.Look elsewhere when:
Sabre\Xml, Symfony Serializer/Config, or raw XMLReader instead.simplexml_load_file/DOMDocument is simpler, better documented, and already in the runtime.maatwebsite/excel or league/csv — don't force XML tooling.Mitigations if adopted: pin the version, wrap it in an internal XmlStreamReader interface, add your own fixture-based tests around it so a replacement is a one-file change, and note it in the dependency-risk register.
To executives: This is a small, free (MIT) library that lets us support large XML data imports — supplier catalogs, partner feeds, sitemaps — without buying an ETL platform or adding infrastructure. It's the difference between "we can't ingest files over a few megabytes" and "we can." Low cost, low commitment, and it's isolated behind our own interface, so the downside is bounded if we later outgrow it.
To engineering: It's a thin iterator over PHP's built-in XMLReader that hands you each node as an array or object with flat memory usage — no DOM, no full-document load, works fine inside queue workers and commands. The API is small and the value is convenience, not magic: we own the mapping, validation, and error handling. Adoption plan: wrap it in a project interface, cover it with fixture tests, pin the version. Real risk is maintenance signal (small package, low star count), not technical fit — and the wrapper makes swapping to Sabre\Xml or raw XMLReader a contained change.
How can I help you explore Laravel packages today?