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

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

niladam/uri
===========

Manipulate and work with your URIs

1.0.1(1y ago)52.6k↑428.6%MITPHPPHP &gt;=7.4CI failing

Since Dec 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/niladam/uri)[ Packagist](https://packagist.org/packages/niladam/uri)[ RSS](/packages/niladam-uri/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

URI
===

[](#uri)

This PHP package provides a robust and flexible way to manipulate and handle URIs, including schemes, hosts, paths, queries, and fragments. It is built on top of `league/uri` and extends its functionality with an intuitive API and additional features like query string handling and fluent URI modification.

[![Latest Version on Packagist](https://camo.githubusercontent.com/7903f26ba431d5c3ffe2efe2190232ccc7b260bfc31509d5db72c4c5e65e6053/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696c6164616d2f7572692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/niladam/uri)[![Total Downloads](https://camo.githubusercontent.com/b0901b7c5d25d28b479782776eeb8837853a67b44806d9eed59977e2340bbf22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e696c6164616d2f7572692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/niladam/uri)

Inspiration
-----------

[](#inspiration)

This package was inspired and is based on Laravel's Uri (`Illuminate\Support\Uri`) from Laravel 11. However, since Laravel 11 requires PHP 8, this package was created to provide similar functionality for PHP 7.4. Some pieces of code have been directly copied from Laravel's implementation to ensure compatibility and feature parity.

Features
--------

[](#features)

- Parse and manipulate URIs
- Handle query strings with ease, including merging, replacing, and removing keys
- Build URIs fluently
- Decode URI strings

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

[](#installation)

Install via Composer:

```
composer require niladam/uri
```

Usage
-----

[](#usage)

### Creating and Parsing a URI

[](#creating-and-parsing-a-uri)

```
use Niladam\Uri\Uri;

$uri = Uri::of('https://user:password@example.com:8080/some/subfolder?view=full#section');

// Access URI components
$scheme   = $uri->scheme();     // "https"
$user     = $uri->user();       // "user"
$password = $uri->password();   // "password"
$host     = $uri->host();       // "example.com"
$port     = $uri->port();       // 8080
$path     = $uri->path();       // "some/subfolder"
$query    = $uri->query()->all(); // ['view' => 'full']
$fragment = $uri->fragment();   // "section"

// String representation of the URI
echo (string)$uri; // "https://user:password@example.com:8080/some/subfolder?view=full#section"
```

### Building a URI Fluently

[](#building-a-uri-fluently)

```
$uri = Uri::of()
    ->withScheme('https')
    ->withHost('example.com')
    ->withUser('john', 'password')
    ->withPort(1234)
    ->withPath('/account/profile')
    ->withFragment('overview')
    ->replaceQuery(['view' => 'detailed']);

echo (string)$uri; // "https://john:password@example.com:1234/account/profile?view=detailed#overview"
```

### Working with Query Strings

[](#working-with-query-strings)

#### Parsing Queries

[](#parsing-queries)

```
$uri = Uri::of('https://example.com?name=Taylor&tags=php&tags=laravel&flagged');

// Access all query parameters
$query = $uri->query()->all();
// [
//     'name'    => 'Taylor',
//     'tags'    => ['php', 'laravel'],
//     'flagged' => ''
// ]
```

#### Modifying Queries

[](#modifying-queries)

```
// Merging Queries
$uri = $uri->withQuery(['tags' => 'framework', 'new' => 'value']);
// Query: "tags=php&tags=laravel&tags=framework&new=value"

// Replacing Queries
$uri = $uri->replaceQuery(['key' => 'value']);
// Query: "key=value"

// Removing Query Keys
$uri = $uri->withoutQuery(['tags', 'new']);
// Query: "key=value"

// Pushing Values onto a Query Key
$uri = $uri->pushOntoQuery('tags', 'newTag');
// Query: "tags=php&tags=laravel&tags=newTag"
```

### Decoding a URI

[](#decoding-a-uri)

```
$decodedUri = $uri->decode();
// Converts encoded URI components to their decoded equivalents
```

Testing
-------

[](#testing)

Run the tests using PHPUnit:

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

1. Fork the repository.
2. Create a feature branch.
3. Make your changes.
4. Submit a pull request.

License
-------

[](#license)

This package is open-source and licensed under the MIT License.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Every ~0 days

Total

2

Last Release

559d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ccbd5f80c8e1c691272c1d4652e4da750d3ba4e08bcc2a8f9801f7f3aadf975?d=identicon)[niladam](/maintainers/niladam)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[symfony/html-sanitizer

Provides an object-oriented API to sanitize untrusted HTML input for safe insertion into a document's DOM.

27941.7M141](/packages/symfony-html-sanitizer)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[php-soap/wsdl

Deals with WSDLs

184.0M19](/packages/php-soap-wsdl)

PHPackages © 2026

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