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

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

timostamm/url-builder
=====================

An URL object to parse, manipulate or create URLs with a fluent interface

v2.0.0(7mo ago)01.7k21AGPL-3.0PHPPHP ^8.0CI failing

Since Sep 28Pushed 3w ago1 watchersCompare

[ Source](https://github.com/timostamm/url-builder)[ Packagist](https://packagist.org/packages/timostamm/url-builder)[ RSS](/packages/timostamm-url-builder/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (1)

PHP URL Object
==============

[](#php-url-object)

[![Build Status](https://camo.githubusercontent.com/2f2437a1764fa5e918c3461dc358bcb6b1b4cfcc96aa955d20c20bdef2255c11/68747470733a2f2f6170692e7472617669732d63692e6f72672f74696d6f7374616d6d2f75726c2d6275696c6465722e706e67)](https://travis-ci.org/timostamm/url-builder)

An URL object to parse, manipulate or create URLs with a fluent interface.

Takes care of proper decoding / encoding of the path, query parameters and credentials.

The object exposes all components of common Web URLs as public properties:

```
$url = new Url('https://peter%40example.com:pass@domain.tld:8080/all+products/search?query=all#fragment');
$url->scheme->get(); // -> "https"
$url->host->get(); // -> "domain.tld"
$url->port->get(); // -> 8080
$url->credentials->username; // peter@example.com
$url->credentials->password;
$url->path->get(); // "all products/search"
$url->path->filename(); // "search"
$url->query->get('query'); // "all"
$url->fragment->get(); // "fragment"
$url->getUrl();
```

URL manipulation:

```
$url->clearHost(); // remove the scheme, host, port, credentials
$url->clearPath(); // remove the path, query, fragment
$url->clear(Url::QUERY | Url::FRAGMENT); // remove only specific components

// replace components with components from another URL
$url->replace('http://example.com/index.html', Url::SCHEME);
$url->replacePath('http://example.com/index.html');

$url = new Url('../styles/main.css');
$url->makeAbsolutePath('http://domain.tld/products/search'); // -> /styles/main.css
$url->makeAbsolute('http://domain.tld/products/search'); // -> http://domain.tld/styles/main.css
```

Path manipulation:

```
$url->path->set('automatically encöded/')
$url->path->normalize(); // resolves /foo/../bar to /bar
$url->filename(); // returns just the filename
```

Query manipulation:

```
$url->query->set('text', 'encöded');
$url->query->has('text');
$url->query->replace([
	'a' => 'foo',
	'b' => 'bar'
]);
foreach( $url->query as list($key, $values) ) {
	print $key . ": " . join(', ', $values) . "\n";
}
```

Credentials manipulation:

```
$url->credentials->username = 'peter@example.com';
$url->credentials->password = 'pass;
$url->credentials->clear(); // removes username and password if present
$url->crdentials->isEmpty(); // Checks whether a username and/or password is present.
$url->crdentials->equals($otherUrl->credentials); // True if both are empty or both are same.
```

Comparing URLs or individual components:

```
$url->equals($otherUrl);
$url->equals('/all+products/search', Url::PATH);
$url->scheme->equals($otherUrl->scheme);
```

Common methods of all components:

```
->isEmpty(); // is the component present?
->clear(); // makes the component empty
->equals($otherurl->component);
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance82

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~917 days

Total

3

Last Release

220d ago

Major Versions

v1.0.1 → 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 (20 commits)")[![ducrot](https://avatars.githubusercontent.com/u/3525119?v=4)](https://github.com/ducrot "ducrot (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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