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

ActiveLibrary

madkom/uri
==========

Uniform Resource Identifier (URI) and Uniform Resource Locator (URL)

1.0.5(9y ago)11.1k11MITPHPPHP ~7

Since Feb 25Pushed 9y ago4 watchersCompare

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

READMEChangelogDependencies (17)Versions (12)Used By (1)

Uniform Resource Identifier (URI) and Uniform Resource Locator (URL)
====================================================================

[](#uniform-resource-identifier-uri-and-uniform-resource-locator-url)

This library implements URI and URL specification and URI Templates, based on [RFC3986](https://tools.ietf.org/html/rfc3986)and [RFC6570](https://tools.ietf.org/html/rfc6570) *(depends on external lib)*.

[![PHP 7.0](https://camo.githubusercontent.com/60f2b2577187e1ceca976d6a9f7a457c657b20dbf85d7a76a3ac28e32e740eb6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e302d3843394342362e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/60f2b2577187e1ceca976d6a9f7a457c657b20dbf85d7a76a3ac28e32e740eb6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e302d3843394342362e7376673f7374796c653d666c6174)[![Build Status](https://camo.githubusercontent.com/be51e79b3c6f32082aba7d3100cab8907e40ce25cc4aa61837d1c820d6bd707e/68747470733a2f2f7472617669732d63692e6f72672f6d61646b6f6d2f7572692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/madkom/uri)[![Latest Stable Version](https://camo.githubusercontent.com/897df38766bbca5417722b74a4b0637810fcd441f96da1383aefa141a90b6a2f/68747470733a2f2f706f7365722e707567782e6f72672f6d61646b6f6d2f7572692f762f737461626c65)](https://packagist.org/packages/madkom/uri)[![Total Downloads](https://camo.githubusercontent.com/8f037cb54154ac6ac8578947ab1b63984bafeac19de6cbe9f11a14089e5e6664/68747470733a2f2f706f7365722e707567782e6f72672f6d61646b6f6d2f7572692f646f776e6c6f616473)](https://packagist.org/packages/madkom/uri)[![License](https://camo.githubusercontent.com/0507a56f12fe2085d34eed8ca7a87689eaa896106b1e496a6b341b06fc686fa7/68747470733a2f2f706f7365722e707567782e6f72672f6d61646b6f6d2f7572692f6c6963656e7365)](https://packagist.org/packages/madkom/uri)[![Coverage Status](https://camo.githubusercontent.com/a95c885659c0da6a81a44fd4c4bdc1ca896b36a6fef50a4569e0ebebb8515a17/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d61646b6f6d2f7572692f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/madkom/uri?branch=master)[![Code Climate](https://camo.githubusercontent.com/172f50e94d9be890ce4133481bffa84d68ebaa2e9bf3fdcdfa4bc8cb7da1f86a/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d61646b6f6d2f7572692f6261646765732f6770612e737667)](https://codeclimate.com/github/madkom/uri)[![Issue Count](https://camo.githubusercontent.com/eba9e6c01a0f26d026e7a8b266ed4f3ade991f1c994634b172a1a56229a41ea4/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d61646b6f6d2f7572692f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/madkom/uri)

---

Features
--------

[](#features)

This library can create objects like:

- **Uri** [RFC3986](https://tools.ietf.org/html/rfc3986) - includes wide abstraction with: **Scheme**, **Authority**, **Path**, **Query**, **Fragment**
- **UriReference** [RFC3986](https://tools.ietf.org/html/rfc3986) - can be resolved with valid **Uri** *(eg. `$resolvedUri = $uriReference->resolve($uri);`)*
- **UriTemplate** [RFC6570](https://tools.ietf.org/html/rfc6570) - produces **Uri** or **UriReference** objects *(depends on template)*

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

[](#installation)

Install with Composer

```
composer require madkom/uri

```

Requirements
------------

[](#requirements)

This library requires *PHP* in `~7` version. At this point this library depends on another own library [madkom/collection](https://packagist.org/packages/madkom/collection) and some external packages:

1. [rize/uri-template](https://packagist.org/packages/rize/uri-template): for UriTemplate impl
2. [true/punycode](https://packagist.org/packages/true/punycode): for IDNA domain names conversion

Usage
-----

[](#usage)

Parsing url string:

```
use Madkom\Uri\UriFactory;
use Madkom\Uri\Uri;

$factory = new UriFactory();

/** @var Uri $uri */
$uri = $factory->createUri('http://user:pass@host.tld/some/path?and=query&param=2#fragment');

$uri->getScheme(); // Instance of \Madkom\Uri\Scheme\Http
$uri->getAuthority(); // Instance of \Madkom\Uri\Authority
$uri->getPath(); // Instance of \Madkom\Uri\Path
$uri->getQuery(); // Instance of \Madkom\Uri\Query
```

> **TODO** Missing fragment impl yet.

Parsing and resolving UriReference:

```
use Madkom\Uri\UriFactory;
use Madkom\Uri\Uri;
use Madkom\Uri\UriReference;

$factory = new UriFactory();

/** @var Uri $uri */
$uri = $factory->createUri('http://user:pass@host.tld/some/path?and=query&param=2#fragment');

/** @var UriReference $uriReference */
$uriReference = $factory->createUriReference('../another/path?and=different');
(string)$uriReference->resolveUri($uri); // http://user:pass@host.tld/some/another/path?and=different
```

Parsing isbn uri:

```
use Madkom\Uri\UriFactory;
use Madkom\Uri\Uri;

$factory = new UriFactory();

/** @var Uri $uri */
$uri = $factory->createUri('isbn:978-83-283-0525-0'); // Instance of \Madkom\Uri\Uri

$uri->getScheme(); // Instance of \Madkom\Uri\Scheme\Custom
$uri->getAuthority(); // NULL
$uri->getPath(); // Instance of \Madkom\Uri\Path with "978-83-283-0525-0"
$uri->getQuery(); // Instance of \Madkom\Uri\Query which is empty
```

Creating URI object:

```
use Madkom\Uri\Uri;
use Madkom\Uri\Scheme\Https;
use Madkom\Uri\Authority;
use Madkom\Uri\Authority\Host\IPv6;
use Madkom\Uri\Authority\UserInfo;
use Madkom\Uri\Path;
use Madkom\Uri\Query;
use Madkom\Uri\Query\Parameter;

/** @var Uri $uri */
$uri = new Uri(
    new Https(),
    new Authority(
        new IPv6('::1'),
        443,
        new UserInfo('user', 'pass')
    ),
    new Path([
        'some',
        'path'
    ]),
    new Query([
        new Parameter('name', 'value')
    ])
);

$uri->toString(); // https://user:pass@[::1]:443/some/path?name=value
(string)$uri; // same as above
```

TODO
----

[](#todo)

- Implement Uri to string conversion
- Implement fragment component
- Replace IRI library with RFC Regex in `\Madkom\Uri\Parser`
- Implement additional parsing modes in `\Madkom\Uri\Parser\Query` for various languages *(parameter duplicate problem)*
- Implement normalization
- Implement UriReference based on *RFC3986*

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2016 Madkom S.A.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

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 ~25 days

Recently: every ~30 days

Total

10

Last Release

3507d ago

Major Versions

0.9.2 → 1.0.0-RC12016-03-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/406fcac8020975863dc6ca1f7cf729eb9755911131bce696ba502218c0536be5?d=identicon)[Madkom](/maintainers/Madkom)

---

Top Contributors

[![brzuchal](https://avatars.githubusercontent.com/u/3149753?v=4)](https://github.com/brzuchal "brzuchal (35 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[helpscout/api

Help Scout API v2 Client

1002.1M4](/packages/helpscout-api)[fr3d/swagger-assertions

Test your API requests and responses against your swagger definition

138850.9k5](/packages/fr3d-swagger-assertions)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113154.9k1](/packages/clue-docker-react)[bear/resource

Hypermedia framework for object as a service

48643.5k32](/packages/bear-resource)

PHPackages © 2026

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