Laravel HTML Dom implementation

1.0.8 2021-07-20 13:09 UTC

This package is auto-updated.

Last update: 2022-07-20 15:26:41 UTC


A Laravel wrapper around the Dom classes of PHP.


  • Load HTML:
$dom = Dom::loadHtml('<html-string>');
  • Search class
$dom->searchClass('class', 'element');
$dom->searchClass(['class1','class2'], 'element');
  • Perform a query

This query will find all divs which contains both class1 and class2 class.


Multiple queries can be combined with or:

	->or(function ($q) {
  • Perform an XPath query on the document:
  • Perform an XPath query on an element:
$elements = $dom->getElementsByTagName("a");
$element = $elements->first();

  • Get the next sibling


Require this package with composer.

composer require eelcol/laravel-html-dom