PHPackages                             zegnat/linkextractor - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. zegnat/linkextractor

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

zegnat/linkextractor
====================

A package that tries to figure out what resources an HTML document links to.

0.1.0(8y ago)441[7 issues](https://github.com/Zegnat/php-linkextractor/issues)0BSDPHP

Since Nov 14Pushed 8y ago3 watchersCompare

[ Source](https://github.com/Zegnat/php-linkextractor)[ Packagist](https://packagist.org/packages/zegnat/linkextractor)[ RSS](/packages/zegnat-linkextractor/feed)WikiDiscussions develop Synced 2w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

LinkExtractor
=============

[](#linkextractor)

The LinkExtractor tries to figure out what resources an HTML document links to.

This tries to solve 2 questions:

1. what constitutes a link between an HTML document and another resource, and
2. how to supply them in a useful (resolved) format.

The class is able to get (and resolve) every URL from a pre-parsed DOM in accordance with where the HTML5 specification allows URLs to be defined. The HTML5 specification is followed after [a GitHub discussion](https://github.com/w3c/webmention/issues/91)about what a link is, and further in person discussion at [IWC Berlin 2017](https://indieweb.org/2017/Berlin).

Using versions &lt; 1.0
-----------------------

[](#using-versions--10)

The current function prototypes are the same as those that will be in 1.0.0. This means you can write the method calls in your code right now and update to 1.0.0 without breaking any of your calls later.

```
function extract(): array
function linksTo(string $url): bool
```

If you rely on specific output or exceptions from these methods however, there might be breaking changes before version 1.0.0. Take a look at [the roadmap to version 1.0.0](https://github.com/Zegnat/php-linkextractor/milestone/1) to get an idea of what is likely to still be changed.

Don’t wait for 1.0.0 with using this library if you need it! Instead, start using it and leave the ever-important feedback.

Install
-------

[](#install)

Via Composer

```
$ composer require zegnat/linkextractor
```

Usage
-----

[](#usage)

```
// Parse an HTML file into a DOMDocument somehow, e.g.:
$dom = new \Zegnat\Html\DOMDocument();
$dom->loadHTML(file_get_contents('http://example.com/index.html'));
// Now initiate the extractor:
$extractor = new \Zegnat\LinkExtractor\LinkExtractor($dom, 'http://example.com/index.html');
var_dump(
    $extractor->linksTo('https://github.com/'),
    $extractor->linksTo('http://www.iana.org/domains/example')
);
/*
bool(false)
bool(true)
*/
```

License
-------

[](#license)

The BSD Zero Clause License (0BSD). Please see the LICENSE file for more information.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3150d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/490579?v=4)[Martijn van der Ven](/maintainers/Zegnat)[@Zegnat](https://github.com/Zegnat)

---

Top Contributors

[![Zegnat](https://avatars.githubusercontent.com/u/490579?v=4)](https://github.com/Zegnat "Zegnat (7 commits)")

---

Tags

domhtmlhtml5

### Embed Badge

![Health badge](/badges/zegnat-linkextractor/health.svg)

```
[![Health](https://phpackages.com/badges/zegnat-linkextractor/health.svg)](https://phpackages.com/packages/zegnat-linkextractor)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[symfony/html-sanitizer

Provides an object-oriented API to sanitize untrusted HTML input for safe insertion into a document's DOM.

27938.2M117](/packages/symfony-html-sanitizer)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k885.1k22](/packages/danog-madelineproto)[spekulatius/phpscraper

PHPScraper, built with simplicity in mind. See tests/ for more examples.

587150.7k3](/packages/spekulatius-phpscraper)[jkphl/micrometa

A meta parser for extracting micro information out of web documents, currently supporting Microformats 1+2, HTML Microdata, RDFa Lite 1.1 and JSON-LD

114166.9k1](/packages/jkphl-micrometa)

PHPackages © 2026

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