PHPackages                             xp-forge/uri - 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. xp-forge/uri

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

xp-forge/uri
============

URIs

v3.1.0(1y ago)1222.5k—0%[1 issues](https://github.com/xp-forge/uri/issues)5BSD-3-ClausePHPPHP &gt;=7.4.0CI passing

Since Mar 24Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/xp-forge/uri)[ Packagist](https://packagist.org/packages/xp-forge/uri)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-forge-uri/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (26)Used By (5)

URI handling
============

[](#uri-handling)

[![Build status on GitHub](https://github.com/xp-forge/uri/workflows/Tests/badge.svg)](https://github.com/xp-forge/uri/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/a4304276007f15614301670cf2f1842d4c3a72dd94efb7da3e6430049e75a2d4/68747470733a2f2f706f7365722e707567782e6f72672f78702d666f7267652f7572692f76657273696f6e2e737667)](https://packagist.org/packages/xp-forge/uri)

A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.

```
  foo://example.com:8042/over/there?name=ferret#nose
  \_/   \______________/\_________/ \_________/ \__/
   |           |            |            |        |
scheme     authority       path        query   fragment
   |   _____________________|__
  / \ /                        \
  urn:example:animal:ferret:nose

```

See

Examples
--------

[](#examples)

### Parsing from a string

[](#parsing-from-a-string)

The most common case will include constructing URIs from a given input string.

```
use util\URI;

$uri= new URI('https://user:password@localhost:8443/index?sort=name#top');
$uri->isOpaque();     // false - it's a hierarchical URI
$uri->scheme();       // "https"
$uri->authority();    // util.Authority("localhost", 8443, "user", util.Secret("password"))
$uri->host();         // "localhost"
$uri->port();         // 8443
$uri->user();         // "user"
$uri->password();     // util.Secret("password")
$uri->path();         // "index"
$uri->query();        // "sort=name"
$uri->params();       // util.uri.Parameters("sort=name")
$uri->param('sort');  // "name"
$uri->fragment();     // "top"
$uri->resource();     // "/index?sort=name#top"
```

### Creating or modifying

[](#creating-or-modifying)

URI instances are immutable. However, a fluent interface is offered via `with()` and `using()`. Both return fresh instances.

```
use util\URI;

$uri= URI::with()->scheme('mailto')->path('timm@example.com')->param('Subject', 'Hello')->create();
$uri->isOpaque();   // true - it's an opaque URI
$uri->scheme();     // "mailto"
$uri->authority();  // null
(string)$uri;       // "mailto:timm@example.com?Subject=Hello"

$copy= $uri->using()->path('cc@example.com')->create();
(string)$copy;      // "mailto:cc@example.com?Subject=Hello"
```

### Resolving URIs

[](#resolving-uris)

Given `http://localhost/home/` as the base URI, you can resolve links in its context using the `resolve()` method:

```
use util\URI;

$uri= new URI('http://localhost/home/');
$uri->resolve('/index.html');       // util.URI
$uri->resolve('index.html');        // util.URI
$uri->resolve('?sort=name');        // util.URI
$uri->resolve('#top');              // util.URI
$uri->resolve('//example.com');     // util.URI
$uri->resolve('https://localhost'); // util.URI
```

### Filesystem

[](#filesystem)

URIs can point to filesystem paths. Converting between the two is not trivial - you need to handle Windows UNC paths correctly. The URI class' `file()` and `asPath()` methods take care of this.

```
use util\URI;

$uri= URI::file('/etc/php.ini');
(string)$uri;       // "file:///etc/php.ini"

$uri= new URI('file://c:/Windows');
$uri->path();       // "C:/Windows"
$uri->asPath();     // io.Path("C:\Windows")

$uri= new URI('file://share/file.txt');
$uri->authority();  // util.Authority("share")
$uri->path();       // "/file.txt"
$uri->asPath();     // io.Path("\\share\file.txt")
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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

Every ~119 days

Recently: every ~296 days

Total

25

Last Release

485d ago

Major Versions

v0.5.0 → v1.0.02017-06-04

v1.4.2 → v2.0.02020-04-10

v2.3.0 → v3.0.02024-03-25

PHP version history (3 changes)v0.1.0PHP &gt;=5.6.0

v2.0.0PHP &gt;=7.0.0

v3.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (109 commits)")

---

Tags

fluent-interfacephprfc-3986urimodulexp

### Embed Badge

![Health badge](/badges/xp-forge-uri/health.svg)

```
[![Health](https://phpackages.com/badges/xp-forge-uri/health.svg)](https://phpackages.com/packages/xp-forge-uri)
```

PHPackages © 2026

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