Skip to content
Simple Html Dom Helper for SMVC
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Simple Html Dom Helper for SMVC

SimpleHtmlDom.php - Is a modified from

A simple PHP HTML DOM parser written in PHP5+, supports invalid HTML, and provides a very easy way to handle HTML elements.

  • A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
  • Require PHP 5+.
  • Supports invalid HTML.
  • Find tags on an HTML page with selectors just like jQuery.
  • Extract contents from HTML in a single line.

##Install Add SimpleHtmlDom.php to app/Helpers


Create an Alias

use Helpers\SimpleHtmlDom;

Usage Example

$html = SimpleHtmlDom::file_get_html('');
$info = array(
    'commits' => trim(strip_tags($html->find('li.commits', 0)->innertext)),
    'watching' => trim($html->find('', 0)->innertext),
    'starred' => trim($html->find('', 1)->innertext),
    'forked' => trim($html->find('', 2)->innertext),
    'desc' => trim($html->find('div.repository-description', 0)->innertext),
    'sitelink' => trim(strip_tags($html->find('div.repository-website', 0)->innertext))

For sites that require a valid user agent, once can be passed like this:

$context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla compatible')));
$html = SimpleHtmlDom::file_get_html('', false, $context);

Find more examples at the important part is to call SimpleHtmlDom::file_get_html('url')

You can’t perform that action at this time.