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.
Architecture fit. halilim/xml-iterator is a framework-agnostic, single-purpose library. It wraps PHP's XMLReader (libxml) in an Iterator that yields each matched node as an array or object, giving us streaming semantics without loading the full document into memory. It is not a Laravel package: there is no service provider, config file, facade, or published conventions. Architecturally it belongs in the infrastructure layer behind a domain-owned interface (e.g. FeedReader), not scattered through controllers or models. Best-fit use cases are large-file ingestion: supplier/catalog feeds, sitemaps, bank/EDI-style exports, and third-party bulk APIs delivered as XML.
Integration feasibility. Low. composer require halilim/xml-iterator plus PSR-4 autoloading is the entire install. Runtime requirements are ext-xmlreader (bundled with libxml, enabled on most builds) and ext-simplexml if node expansion is used. There is no version conflict with the framework, no bootstrapping cost, and it composes cleanly inside a queued job or artisan command. A proof of concept against one production-sized file should take under a day.
Technical risk.
SimpleXMLElement assumptions.Key questions for the maintainer / spike.
XMLReader options exposed, and can we force LIBXML_NONET and disable entity substitution globally?php://temp, gzipped files) or only local paths?false, or partial iteration?Stack fit. Treat it as a low-level utility: one thin adapter class per feed format, implementing an internal interface, returning typed DTOs or arrays. Keep the package namespace confined to app/Infrastructure/Xml/ (or equivalent) so the rest of the codebase never imports it directly. This preserves the option to swap in prewk/xml-string-streamer, a hand-rolled XMLReader loop, or a SaaS parser later.
Migration path. For any existing simplexml_load_file / DOMDocument code, migrate incrementally:
Compatibility. No framework coupling means no upgrade friction from Laravel majors, but it also means no framework-level safety net: no assertXml test helpers, no Http-style fakes, no container bindings. Ensure the deploy image (including any FPM/queue/CI containers) has ext-xmlreader; this is the single most common "works locally, fails in prod" cause for this class of library. Pin a caret constraint in composer.json and commit the lock file.
Sequencing.
Maintenance. Small, stable surface area — the public API is a handful of methods, so upgrade churn should be minimal. The real maintenance obligation is ours: version pinning, composer audit in CI, and a documented contingency plan for adoption/abandonment. Budget a periodic review of the upstream repository rather than continuous upkeep.
Support. Community-only via GitHub issues; no vendor SLA, no Laravel-specific documentation, no Stack Overflow corpus. Assume the team is self-supporting and write internal runbook documentation at integration time — this is the single highest-leverage operational investment for a package this small.
Scaling. This is the package's core strength: memory stays roughly flat regardless of document size, so multi-gigabyte feeds become feasible on ordinary workers. Scale-out is horizontal via queue workers; throughput is CPU-bound by per-node conversion, so expect to tune batch sizes, job timeouts, and worker concurrency rather than memory limits. Watch for the pathological case where one node is very large (deeply nested or a single massive record) — the constant-memory guarantee is per-node, not absolute.
Failure modes to instrument for.
ext-xmlreader in a container or host → fail fast at deploy time with a health check.Ramp-up. The library itself is learnable in hours. The real ramp-up is XMLReader semantics — namespaces, cursor position, expansion behaviour, and error handling — plus the domain's mapping rules. Estimate one developer-day for a mid-level engineer to be productive and two to three days to be genuinely confident with adversarial inputs. Because there are no framework conventions to lean on, pair the adoption with an internal README covering the adapter contract, security settings, and the golden-corpus test suite.
How can I help you explore Laravel packages today?