paquettg/php-html-parser
Fast, lightweight HTML parser for PHP that turns messy markup into a DOM-like tree. Crawl and scrape pages, query elements with CSS selectors, and extract text/attributes easily. Works with imperfect HTML and focuses on simple, fluent usage.
Adopt When:
find('div.class') or filter('img[src*=logo]')).Look Elsewhere If:
For Executives: "This package lets us build HTML parsing features 10x faster without hiring specialized engineers. For example, we could launch a competitor price-scraping tool in weeks instead of months, or clean up user-generated content to reduce moderation costs. It’s MIT-licensed (no legal risk), widely adopted (2.4K stars), and integrates seamlessly with our PHP stack. The trade-off? We’d avoid the complexity of headless browsers for simple HTML tasks, saving dev time and cloud costs."
For Engineering:
"This is a drop-in replacement for jQuery’s DOM methods in PHP. Need to extract all src attributes from images? One line: $parser->find('img')->attr('src'). Want to sanitize HTML input? Strip scripts with $parser->remove('script'). It’s lighter than Symfony’s DOMCrawler for basic tasks and plays well with Laravel. Downside: Not ideal for JS-heavy pages or large-scale scraping—we’d need to pair it with a queue system for heavy loads. Let’s prototype it for [X use case] and compare performance to our current [legacy solution]."
For Developers: *"Imagine writing CSS selectors in PHP like you would in JavaScript. This package lets you:
$nodes = $parser->find('div.content p');$parser->attr('href', 'https://example.com');$parser->children()->each(fn($node) => ...);
It’s easier to debug than regex for HTML and avoids the verbosity of DOMDocument. Perfect for quick scripts or features where we’d otherwise reach for str_replace() or preg_match_all()."*How can I help you explore Laravel packages today?