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 2d 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 14% 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

3103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3bb51da70a2669f3099430721c36fb45ab255b0486c2b3da3c9cff77db62d95?d=identicon)[Zegnat](/maintainers/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

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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