PHPackages                             timostamm/url-finder - 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. timostamm/url-finder

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

timostamm/url-finder
====================

Find and replace URLs in HTML and CSS documents

v2.0.0(7mo ago)21.7k1AGPL-3.0PHPPHP ^8.0CI passing

Since Sep 28Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/timostamm/url-finder)[ Packagist](https://packagist.org/packages/timostamm/url-finder)[ RSS](/packages/timostamm-url-finder/feed)WikiDiscussions master Synced today

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

PHP URL Finder
==============

[](#php-url-finder)

[![build](https://github.com/timostamm/url-finder/workflows/CI/badge.svg)](https://github.com/timostamm/url-finder/actions?query=workflow:%22CI%22)[![Packagist PHP Version](https://camo.githubusercontent.com/2501862422b179e737d7b28865111aa87da79699757148eb572ac693366311a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f74696d6f7374616d6d2f75726c2d66696e6465722f706870)](https://camo.githubusercontent.com/2501862422b179e737d7b28865111aa87da79699757148eb572ac693366311a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f74696d6f7374616d6d2f75726c2d66696e6465722f706870)[![GitHub tag](https://camo.githubusercontent.com/ef9e3829b373fb7301c6321fedd66034cbbe8f17e11795a9dad4b2e8aa70b6e3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f74696d6f7374616d6d2f75726c2d66696e6465723f696e636c7564655f70726572656c65617365733d26736f72743d73656d76657226636f6c6f723d626c7565)](https://github.com/timostamm/url-finder/releases/)

Find and replace URLs in HTML, CSS and Markdown documents.

Example input HTML:

```

    .bg-img { background-image: url(../images/h.jpg); }

  ...
```

Find all jpegs on our domain and move them to /images/

```
$documentUrl = 'http://domain.tld/products/all.html';
$finder = UrlFinder::create($html, $documentUrl);

foreach ($finder->find('*domain.tld/*.jpg') as $url) {
  $newpath = '/images/' . $url->path->filename();
  $url
    ->replacePath($newpath)
    ->makeAbsolute()
    ->clearHost();
}

$finder->getDocument(); // returns the updated HTML string
```

The result:

```

    .bg-img { background-image: url(/images/h.jpg); }

  ...
```

The UrlFinder takes care of proper quoting of URLs in attributes, url-notations in style-attributes and url- notation within style-tags.

Using the fluid collection interface:

```
$urls = $finder
  ->find('*') // matches the entire absolute URL
  ->matchHost('*')
  ->matchPath('*')
  ->onlyHttps()
  ->matchFilenameNot('*.less');
  // etc.

$urls->count();
$urls->toArray();
$urls->first();
foreach($urls as $url) {}
```

Updating URLs:

```
$url->query->set('text', 'value');
$url->clear( Url::CREDENTIALS );
```

See  for documentation of the URL object.

Finding URLs in CSS works exactly the same:

```
$finder = UrlFinder::create($css, 'http://domain.tld/styles/main.css');
$finder->find()->first()->makeAbsolute();
$finder->getDocument();
```

Please note that import statements are not suported and you have to follow stylesheet-links yourself.

### Markdown support

[](#markdown-support)

Markdown support is experimental right now. Caveats:

- Link / image titles are not supported and will raise an error
- HTML with links within markdown is ignored
- Markdown is not available using UrlFinder::create, use new MarkdownUrlFinder()

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance64

Regular maintenance activity

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 78.6% 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 ~611 days

Total

4

Last Release

217d ago

Major Versions

v1.0.2 → v2.0.02025-10-06

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

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6364011a12f22cb5046056371bde6170218218c560eddfdc08b4644b7648af78?d=identicon)[timostamm](/maintainers/timostamm)

---

Top Contributors

[![timostamm](https://avatars.githubusercontent.com/u/4289451?v=4)](https://github.com/timostamm "timostamm (22 commits)")[![ducrot](https://avatars.githubusercontent.com/u/3525119?v=4)](https://github.com/ducrot "ducrot (6 commits)")

---

Tags

csshtmlurl-replace

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/timostamm-url-finder/health.svg)

```
[![Health](https://phpackages.com/badges/timostamm-url-finder/health.svg)](https://phpackages.com/packages/timostamm-url-finder)
```

###  Alternatives

[matthiasmullie/minify

CSS &amp; JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.

2.0k30.5M336](/packages/matthiasmullie-minify)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[phpstrap/phpstrap

Bootstrap layout generator

1214.7k](/packages/phpstrap-phpstrap)

PHPackages © 2026

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