PHPackages                             thesmart/php-url - 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. thesmart/php-url

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

thesmart/php-url
================

Create, manipulate, and output any URL easily. Convert between relative and absolute URLs. Map URLs to their canonical equivalent.

v0.1.0(13y ago)218MITPHPPHP &gt;=5.3.0

Since Sep 12Pushed 13y agoCompare

[ Source](https://github.com/thesmart/php-url)[ Packagist](https://packagist.org/packages/thesmart/php-url)[ Docs](https://github.com/thesmart/php-url)[ RSS](/packages/thesmart-php-url/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-url
=======

[](#php-url)

Create, manipulate, and output any URL easily. Convert between relative and absolute URLs. Map URLs to their canonical equivalent.

Usage
-----

[](#usage)

\###Construct a URL from a string

```
$url = new Url('http://example.com/');
echo (string)$url;
```

```
http://example.com/

```

\###Mutate the URL in different ways

```
$url = new Url();
$url->setScheme('https://')->setHost('www.reddit.com')->setPath('/r/programming');
echo (string)$url;
```

```
https://www.reddit.com/r/programming

```

\###Access the arguments from a URL

**NOTE**: automatically alphabetizes the arguments.

```
$url = new Url('http://example.com?x=0&a=1&b=2');
var_dump($url->getQuery());
var_dump($url->getQueryStr());
```

```
array(3) {
  ["a"]=>
  string(1) "1"
  ["b"]=>
  string(1) "2"
  ["x"]=>
  string(1) "0"
}
string(11) "a=1&b=2&x=0"

```

\###Handles trailing-slash like you would expect

```
$url = new Url('http://example.com');
var_dump((string)$url);
$url = new Url('http://example.com/');
var_dump((string)$url);
$url = new Url('http://example.com');
$url->setPath('/');
var_dump((string)$url);
```

```
string(18) "http://example.com"
string(19) "http://example.com/"
string(19) "http://example.com/"

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

4993d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11f682ea6d98e41ccb56db0a284ac5b085fd31d40c3119cf8c3e493f87498c0a?d=identicon)[thesmart](/maintainers/thesmart)

---

Top Contributors

[![thesmart](https://avatars.githubusercontent.com/u/280877?v=4)](https://github.com/thesmart "thesmart (3 commits)")

---

Tags

urlquery-stringquerycanonicalrelative pathabsolute path

### Embed Badge

![Health badge](/badges/thesmart-php-url/health.svg)

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

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[spatie/url

Parse, build and manipulate URL's

73914.3M97](/packages/spatie-url)[jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

6737.4M62](/packages/jbroadway-urlify)[sabre/uri

Functions for making sense out of URIs.

29335.2M40](/packages/sabre-uri)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15439.5M49](/packages/spomky-labs-base64url)[misd/linkify

Converts URLs and email addresses in text into HTML links

1122.9M10](/packages/misd-linkify)

PHPackages © 2026

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