2017 © Pedro Peláez
 

library php-html

PHP HTML Utilities

image

hugsbrugs/php-html

PHP HTML Utilities

  • Friday, June 2, 2017
  • by hugsbrugs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php-html

This librairy provides utilities function to ease HTML manipulation, (*1)

Build Status Coverage Status, (*2)

Install

Install package with composer, (*3)

composer require hugsbrugs/php-html

In your PHP code, load librairy, (*4)

require_once __DIR__ . '/vendor/autoload.php';
use Hug\Html\Html as Html;

Usage

Test if a link is external from given domain, (*5)

$bool = Html::is_external_link($domain = 'maugey.fr', $link = 'http://maugey.fr/coucou.html');

Test if a link is from given domain, (*6)

$bool = Html::is_domain_link($domain = 'tata.maugey.fr', $link = 'http://maugey.fr/coucou.html');

Replace all relatives path in HTML (script, style, img) with absolute ones with given page URL, (*7)

$html = Html::replace_rel_to_abs_paths($html, $page_url = 'http://portail.free.fr/m/');

Build an absolute link from relative link and page URL, (*8)

$html = Html::rel_to_abs($rel = '/js/script.js', $base = 'http://portail.free.fr/m/');

Return array of backlinks from given HTML page and domain, (*9)

$html = Html::find_backlinks($html, $domain = 'www.free.fr');

Returns array of canonicals from string, (*10)

$array = Html::get_canonicals($canonical_content = 'index, follow, noindex, noarchive');

Replaces all links in HTML by https, (*11)

$html = Html::set_href_ssl($html);

Set UTF-8 Charset in HTML page with correct syntax depending on Doctype, (*12)

$html = Html::set_charset_utf_8($html);

Remove all external link from HTML with given domain, (*13)

$html = Html::remove_external_links($html, $domain = 'free.fr');

Remove all and , (*14)

$html = Html::remove_script_style($html);

Extract , (*15)

content from HTML page
$body = Html::extract_body_content($html);

Check for tag, (*16)

$is_spa = Html::is_spa($html);

Get all links, (*17)

$links = Html::get_links($html);

Get external links, (*18)

$external_links = Html::get_external_links($html);

Get internal links, (*19)

$internal_links = Html::get_internal_links($html);

Get images, (*20)

$images = Html::get_images($html);

Obfuscate email to be incorporated in HTML, (*21)

$email = Html::DJNikMail($str = 'tatayoyo@free.fr');

Unit Tests

phpunit --bootstrap vendor/autoload.php tests

Author

Hugo Maugey visit my website ;), (*22)

The Versions