wikimedia/idle-dom
IDLeDOM provides PHP interfaces and helper traits for the DOM as defined by Web IDL, enabling type-safe documents, nodes, and elements with interchangeable implementations. It helps libraries offer standards-compliant DOM behavior without binding to a single backend.
What the package actually is. wikimedia/idle-dom is not a Laravel package and not an application-facing library. It is a set of PHP interfaces (namespace IDLeDOM\) that model the WHATWG DOM spec — Document, Element, Node, NodeList, etc. — plus a small amount of supporting code. It deliberately contains no parser and no concrete DOM implementation. On its own it does essentially nothing at runtime; it only becomes useful when paired with an implementing library (canonically wikimedia/remex-html for HTML5 parsing) or when used to type-hint and mock DOM behavior in tests.
Architecture fit. Poor-to-neutral for a typical Laravel application. Laravel's ecosystem, and PHP generally, assumes ext-dom (DOMDocument, DOMXPath, libxml). That extension is fast, ubiquitous, and already a de facto platform requirement. Introducing IDLeDOM means introducing a second, parallel DOM abstraction with no Eloquent, HTTP, queue, or view-layer integration surface whatsoever. There is no service provider, no config file, no facade, and nothing to register in config/app.php.
Integration feasibility. Mechanically trivial: composer require wikimedia/idle-dom and you can type-hint IDLeDOM\Document. Practically, the only defensible reasons to adopt it are:
ext-dom in the target runtime (rare, and usually false for Laravel — many packages require ext-dom).Absent one of those, this is an unnecessary abstraction layer.
Technical risk. Moderate, and mostly governance-shaped rather than code-shaped:
Key questions for the team.
ext-dom cannot satisfy, or is this abstraction for its own sake?remex-html? a custom one?), and who owns that choice?ext-dom be cheaper?Stack fit. Treat this as a low-level domain dependency inside a single service class, never as a cross-cutting concern. The correct pattern is a hexagonal one: define your own narrow port (e.g., HtmlExtractionService), implement it with either ext-dom or IDLeDOM + remex-html, and keep IDLeDOM\* type hints out of controllers, models, jobs, and anything else that leaks into the framework layer. IDLeDOM types in an Eloquent model or a queued job payload would be a design defect.
Migration path. There is nothing to migrate to — this is greenfield adoption, not a replacement for an existing Laravel subsystem. If the motivation is replacing DOMDocument usage, the migration is: (a) inventory all DOMDocument/DOMXPath call sites, (b) wrap each behind the port interface, (c) swap the implementation behind a config flag, (d) compare output on a golden corpus of real HTML. Step (d) is non-negotiable; HTML5 parsing behavior differs meaningfully between libxml and RemexHtml on malformed input, which is exactly the input real-world scrapers and sanitizers encounter.
Compatibility. No autoload or namespace collision risk — IDLeDOM uses IDLeDOM\, not DOM\, so it coexists with ext-dom. Verify the PHP constraint in composer.json against your runtime matrix before committing; the package targets modern PHP 7/8 and will not help you on legacy runtimes, which is often the very reason people reach for pure-PHP DOM in the first place. Licensing is MIT and compatible with any Laravel project. No Laravel version coupling exists, which is both a feature (nothing breaks on Laravel upgrades) and a signal (nothing is tested against Laravel either).
Sequencing.
ext-dom and with IDLeDOM + remex-html. Measure correctness on malformed HTML and measure throughput.ext-dom adapter as the default and the IDLeDOM adapter behind a flag.Maintenance. Near-zero runtime surface: no services, no daemons, no config, no migrations, no scheduled work. The maintenance cost is entirely upstream-tracking. Budget for someone reading Gerrit or the Packagist release feed, because GitHub notifications will be silent. Pin an exact version in composer.json and upgrade deliberately; do not float on a branch alias against a mirror.
Support. This is the weakest dimension. There is no GitHub issue tracker in practice, no vendor SLA, and no Laravel community familiarity. Wikimedia's developer-access process is the support channel, which is unreasonable for a product team to depend on for routine questions. Escalation realistically means reading MediaWiki source and patching locally. A vendor fork should be assumed as the contingency, which means the license and mirror structure must permit it (MIT does; the mirror explicitly encourages forking).
Scaling. If IDLeDOM is backed by a pure-PHP implementation, expect significantly lower throughput and higher memory per document than ext-dom. PHP-userland DOM construction allocates an object per node; libxml-backed DOMDocument does not. For a request-path HTML sanitizer or a scraper processing thousands of documents per job batch, this is the deciding factor. Profile before committing. Concurrency is unaffected (no shared state, no I/O), so horizontal scaling behavior is ordinary — the cost is per-unit CPU and memory, not architectural.
Failure modes.
ext-dom on malformed input, silently changing extraction or sanitization results. Mitigate with the golden-corpus diff in the integration plan.IDLeDOM\* types propagate into application code, making the eventual removal expensive. Mitigate with an architectural rule and a static-analysis check on the namespace.remex-html as an unplanned dependency. Mitigate by stating the pairing requirement explicitly in the decision record.Ramp-up. Low for anyone who knows the DOM spec — the interface names are deliberately spec-faithful, so a frontend-adjacent developer will find it familiar. The real ramp-up cost is organizational: explaining to the team why a second DOM abstraction exists in a codebase that already has a perfectly good native one. That question will be asked repeatedly at code review unless the decision record answers it in one sentence. Given a 0.005 viability score and zero visible dependents, the default recommendation is do not adopt unless a specific, documented constraint rules out ext-dom; if such a constraint exists, adopt narrowly, behind a port, pinned and forked-ready.
How can I help you explore Laravel packages today?