PHPackages                             willwashburn/canonical - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. willwashburn/canonical

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

willwashburn/canonical
======================

return the canonical url from a string of html

v3.1.3(6y ago)284.2k—4.8%1[1 issues](https://github.com/willwashburn/canonical/issues)1MITPHPPHP &gt;=5.4.0CI failing

Since Mar 12Pushed 6y ago2 watchersCompare

[ Source](https://github.com/willwashburn/canonical)[ Packagist](https://packagist.org/packages/willwashburn/canonical)[ Docs](https://github.com/willwashburn/canonical)[ RSS](/packages/willwashburn-canonical/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (1)

Canonical ⛪ [![Travis](https://camo.githubusercontent.com/c9fe3cc6c82fa510e7db4f742d15c8edb0ae07adcca4b0ca36113c12dbae8e45/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f77696c6c776173686275726e2f63616e6f6e6963616c2e737667)](https://travis-ci.org/willwashburn/canonical) [![Packagist](https://camo.githubusercontent.com/21b45fe68bed6fdf2dcb1f581aeaf01bf2bb4934d98296d939729beb142d96cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77696c6c776173686275726e2f63616e6f6e6963616c2e737667)](https://packagist.org/packages/willwashburn/canonical) [![Packagist](https://camo.githubusercontent.com/9bf1cec2bc44adfcfd400f68816d4aa6129843bda2d8892ef9c0dabdcbe24768/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77696c6c776173686275726e2f63616e6f6e6963616c2e737667)](https://packagist.org/packages/willwashburn/canonical) [![MIT License](https://camo.githubusercontent.com/afd324accd8fe3012455a6c47b48348587dc85333cf6ae12155eb3e5d1e26918/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77696c6c776173686275726e2f63616e6f6e6963616c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/willwashburn/canonical/blob/master/LICENSE)
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#canonical-church----)

Return the canonical url from a string of html

Usage
-----

[](#usage)

```
$canonical = new \Canonical\Canonical;

// using some string of html fetched via curl or file get contents or carrier pigeon
$html = file_get_contents('website.html');

$canonical->url($html);
//// http://www.yourlink.com
```

Installation
------------

[](#installation)

Use composer

`composer require willwashburn/canonical`

Alternatively, add `"willwashburn/canonical": "~3.1"` to your composer.json

Change Log
----------

[](#change-log)

- v3.1.3 - Improve regex to match `window.location =`
- v3.1.2 - Loosen dom crawler class requirements
- v3.1.1 - Remove Javascript redirects from default extractors
- v3.1.0 - Use more consistent naming for extractor class; drop nightly support
- v3.0.0 - Parse Javascript redirects similar to http-refresh tags
- v2.1.1 - Fix bug when calling same html twice with same instance of canonical
- v2.1.0 - Allow accessing url with utm params and hash anchors in return object
- v2.0.0 - Parse http-refresh tags; New namespace; New return object
- v1.2.1 - Favor canonical tag over og:url tag
- v1.2.0 - Remove utm params and hash anchors
- v1.1.0 - Search for twitter:url meta tags if no others are found
- v1.0.2 - Fix support for php 5.4
- v1.0.1 - Clear crawler before use
- v1.0.0 - Basic tag finding for og:link and link rel=canonical using symfony dom crawler

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~105 days

Recently: every ~60 days

Total

14

Last Release

2402d ago

Major Versions

v1.2.1 → v2.0.02018-04-04

v2.1.1 → v3.0.02019-04-08

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.1PHP &gt;=5.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/957608?v=4)[Will Washburn](/maintainers/willwashburn)[@willwashburn](https://github.com/willwashburn)

---

Top Contributors

[![willwashburn](https://avatars.githubusercontent.com/u/957608?v=4)](https://github.com/willwashburn "willwashburn (23 commits)")[![irazasyed](https://avatars.githubusercontent.com/u/1915268?v=4)](https://github.com/irazasyed "irazasyed (1 commits)")

---

Tags

canonicalcanonical urlog url

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/willwashburn-canonical/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[spatie/crawler

Crawl all internal links found on a website

2.8k18.5M67](/packages/spatie-crawler)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49617.1k](/packages/blackfire-player)[drupal/drupal-extension

Drupal extension for Behat

22215.7M173](/packages/drupal-drupal-extension)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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