PHPackages                             hugsbrugs/php-html - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hugsbrugs/php-html

ActiveLibrary

hugsbrugs/php-html
==================

PHP HTML Utilities

1.2(4y ago)074HTML

Since Apr 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hugsbrugs/php-html)[ Packagist](https://packagist.org/packages/hugsbrugs/php-html)[ RSS](/packages/hugsbrugs-php-html/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

php-html
========

[](#php-html)

This librairy provides utilities function to ease HTML manipulation

[![Build Status](https://camo.githubusercontent.com/38d6e163127accb05cabda52c3e9a1adf5bfb620ca3e37762748c9a3d793f7b6/68747470733a2f2f7472617669732d63692e6f72672f6875677362727567732f7068702d68746d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hugsbrugs/php-html)[![Coverage Status](https://camo.githubusercontent.com/5d4b8f776d616db3ff8153066cccaf1febf81ae441a6fc76048ab6fc35eb5b96/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6875677362727567732f7068702d68746d6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hugsbrugs/php-html?branch=master)

Install
-------

[](#install)

Install package with composer

```
composer require hugsbrugs/php-html

```

In your PHP code, load librairy

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

Usage
-----

[](#usage)

Test if a link is external from given domain

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

Test if a link is from given domain

```
$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

```
$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

```
$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

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

Returns array of canonicals from string

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

Replaces all links in HTML by https

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

Set UTF-8 Charset in HTML page with correct syntax depending on Doctype

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

Remove all external link from HTML with given domain

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

Remove all and &lt;style&gt; tags from HTML

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

Extract content from HTML page

```
$body = Html::extract_body_content($html);
```

Check for tag

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

Get all links

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

Get all iframes

```
$links = Html::get_iframes($html);
```

Get external links

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

Get internal links

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

Get images

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

Obfuscate email to be incorporated in HTML

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

Unit Tests
----------

[](#unit-tests)

```
phpunit --bootstrap vendor/autoload.php tests

```

Author
------

[](#author)

Hugo Maugey [visit my website ;)](https://hugo.maugey.fr)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~442 days

Total

3

Last Release

1698d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc04033020c3e5219ac30edf7d7362952e88ea64a0de2f41b89559f849f09901?d=identicon)[hugsbrugs](/maintainers/hugsbrugs)

---

Top Contributors

[![hugsbrugs](https://avatars.githubusercontent.com/u/4385090?v=4)](https://github.com/hugsbrugs "hugsbrugs (12 commits)")

### Embed Badge

![Health badge](/badges/hugsbrugs-php-html/health.svg)

```
[![Health](https://phpackages.com/badges/hugsbrugs-php-html/health.svg)](https://phpackages.com/packages/hugsbrugs-php-html)
```

###  Alternatives

[hugsbrugs/php-sftp

PHP SFTP Utilities

28144.5k1](/packages/hugsbrugs-php-sftp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
