league/html-to-markdown
Convert HTML to Markdown in PHP with league/html-to-markdown. Create an HtmlConverter, pass valid HTML to convert(), and get clean Markdown back. Useful for editing legacy HTML, storing content as HTML while authoring in Markdown, and turning HTML email into plain text.
Architecture fit: Unchanged. The package remains a lightweight, standalone PHP library with minimal dependencies (DOM, XML extensions) that fits cleanly into Laravel's ecosystem. It integrates via Composer and can be used in service layers or controllers without Laravel-specific modifications. The 5.1.4 release introduces no API, namespace, or configuration changes, so the architectural fit is identical.
Integration feasibility: High, and now slightly lower-risk to adopt. No new configuration, service provider, or facade is required. The only change is a version constraint: pin league/html-to-markdown to ^5.1.4 (or >=5.1.4) so that the security fix cannot be resolved away by a stale lockfile.
Technical risk: Moderate, but the risk profile has shifted. Previously the dominant risk was output correctness and injection via unsanitized input; 5.1.4 adds a confirmed denial-of-service class of risk in all prior versions. Specifically, conversion time grew with the square of the number of sibling elements sharing a parent (list items, <pre>, <code>, table rows and cells, and preserved HTML tags on every PHP version; all other elements on PHP 8.0 and below). Any endpoint that converts user-supplied HTML was a viable CPU-exhaustion target. The fix does not alter Markdown output, so it is a drop-in patch with no regression surface in generated content. Residual risks remain: input sanitization (e.g. HTML Purifier) is still required for untrusted content, edge cases in complex nested structures persist, PHP 7.2+ is still required, and Markdown variant support is still limited.
Key questions:
Stack fit: Excellent and unchanged. Usable directly in controllers, services, or as a model accessor, with no additional Laravel-specific packages. The container can manage a converter instance; no new bindings are needed.
Migration path: Treat this as a security patch, not a feature upgrade. Bump the constraint to ^5.1.4, run composer update league/html-to-markdown, and verify the lockfile resolves to 5.1.4 or later in every environment (including any separate worker, queue, or Lambda images). Because output is byte-identical to 5.1.3, the existing conversion test suite is sufficient regression coverage; no new fixtures are required. If conversion logic was previously duplicated inline rather than encapsulated, this is a good moment to consolidate it into a single service so the patched version is used everywhere.
Compatibility: Unchanged. Laravel 5.5+ / PHP 7.2+, standard dom and libxml extensions. No deprecations, no removed methods, no changed defaults.
Sequencing:
composer.json / composer.lock across all services and images to confirm which versions of the package are actually deployed.^5.1.4 and update; confirm the resolved version per environment.Maintenance: Low and unchanged in steady state, but this release changes the maintenance posture: the package now has a disclosed security advisory history, so it should be tracked by automated dependency alerting rather than periodic manual bumps. Patching is a one-line constraint change with no code edits.
Support: Community support via GitHub issues; the League remains reputable and shipped a coordinated advisory with a same-day patch, which is a positive signal for responsiveness. Expect no vendor escalation path — internal ownership of the upgrade still sits with the team.
Scaling: The 5.1.4 fix is directly relevant to scaling. Conversion cost for documents with many sibling elements (long lists, wide tables, many <pre>/<code> blocks, preserved tags) is now linear rather than quadratic, so worst-case CPU per request drops substantially and becomes predictable. This materially improves tail latency and capacity headroom for bulk conversion jobs — for example, converting large exported documents or batch backfills. Memory behavior of DOMDocument is unchanged; extremely large documents still warrant size caps and, where applicable, chunking or queue-based processing.
Failure modes: The quadratic-time path is closed in 5.1.4, but the following remain: malformed HTML producing unexpected output rather than an error; unsanitized input creating injection risk downstream; imperfect conversion of complex nested elements; and unbounded input size still causing memory pressure or long runtimes even at linear cost. Note that this fix addresses CPU consumption, not memory — a size limit is still the control for memory exhaustion.
Ramp-up: Minimal and unchanged. Simple API, clear docs, and because 5.1.4 changes no output, developers need no new mental model. The one thing to teach is procedural: untrusted HTML conversion is a security-sensitive path, so pinning to a patched version and enforcing sanitization plus input limits are part of the definition of done, not optional hardening.
How can I help you explore Laravel packages today?