Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Simple Html Dom Bundle Laravel Package

mushroomcloud/simple-html-dom-bundle

A Symfony bundle that integrates the Simple HTML DOM library, offering service configuration for parsing, traversing, and manipulating HTML documents in PHP. Handy for scraping, content extraction, and DOM-style edits in Symfony apps.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install with composer require mushroomcloud/simple-html-dom-bundle.
  • This is a Symfony bundle, not a Laravel package. In Laravel there is no bundle registration step and no Laravel service provider — you will generally use the underlying simple-html-dom library directly, or only pull this package in for a Symfony application.
  • Look first at the bundle class MushroomCloud\SimpleHtmlDomBundle\MushroomCloudSimpleHtmlDomBundle and the config key mushroom_cloud_simple_html_dom. Those are the two entry points you will touch.
  • First use case: turning an HTML string or URL into a queryable DOM and extracting content. In Symfony, register the bundle and consume the parser service. In Laravel, the pragmatic path is to call the underlying str_get_html() / file_get_html() API from a small service class.
  • If you are coming from martyrer/simple-html-dom-bundle, this is a breaking rename: update the composer requirement, namespace imports, bundle class reference, and the config key before anything else.

Implementation Patterns

  • Symfony wiring: register MushroomCloudSimpleHtmlDomBundle in config/bundles.php, configure it under mushroom_cloud_simple_html_dom, then inject the parser service into your classes instead of calling the global helpers.
  • Laravel wiring: skip the bundle and use the underlying simple-html-dom API inside a dedicated class (e.g. HtmlParser) registered in the container. Return typed DTOs/arrays rather than leaking simple_html_dom_node objects through your app.
  • Encapsulate parsing behind an interface so you can swap to symfony/dom-crawler, symfony/css-selector, or another parser later without touching call sites.
  • Use it in console commands and queued jobs for scraping/enrichment, but apply throttling, timeouts, and response caching — parsing is CPU/memory heavy.
  • Testing pattern: feed fixture HTML strings into your wrapper and assert on extracted values; mock the parser interface in feature tests so no network is involved.
  • Integration tip: prefer targeted find('selector') calls over whole-document traversal, and free DOM objects ($dom->clear()) when processing batches.

Gotchas and Tips

  • Breaking change in 2.0: the package was renamed from martyrer/simple-html-dom-bundle to mushroomcloud/simple-html-dom-bundle. Update the composer requirement, namespace (MushroomCloud\SimpleHtmlDomBundle), bundle class (MushroomCloudSimpleHtmlDomBundle), and config key (mushroom_cloud_simple_html_dom). Miss the config key and your Symfony config will be silently ignored.
  • Not a Laravel package: no auto-discovery, no facade, no Laravel-specific config publishing. Don't expect config/mushroom_cloud_simple_html_dom.php to appear in a Laravel app.
  • simple_html_dom is memory-hungry and older; set memory_limit expectations and avoid parsing very large documents. For new Laravel work, symfony/dom-crawler is usually the better default.
  • Debugging: malformed HTML can produce surprising trees. Dump with $dom->save() or $dom->outertext to inspect what the parser actually built.
  • Extension point: the bundle exposes the parser as a service, so you can decorate or alias it to add logging, caching, or a different parser implementation.
  • Pin the new major version in composer.json; teams migrating from martyrer/... should do the rename in one commit to avoid mixed old/new references.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect