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

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

vdhicts/uri-builder
===================

Easily parse, build or manipulate an URI.

v1.2.0(1mo ago)11MITPHPPHP ^8.3CI passing

Since May 24Pushed 1mo agoCompare

[ Source](https://github.com/vdhicts/uri-builder)[ Packagist](https://packagist.org/packages/vdhicts/uri-builder)[ Docs](https://github.com/vdhicts/uri-builder)[ RSS](/packages/vdhicts-uri-builder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (5)Used By (0)

URI builder
===========

[](#uri-builder)

This is a simple URI builder in PHP. It allows you to create and manipulate URIs easily. It also fully supports repeating query parameters.

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

[](#requirements)

This package requires PHP 8.3 or higher.

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

[](#installation)

You can install the package via Composer:

```
composer require vdhicts/uri-builder
```

Usage
-----

[](#usage)

This package provides three main usages:

- Parsing the URI
- Building the URI
- Manipulating the URI

### Parsing the URI

[](#parsing-the-uri)

You can parse a URI using the `Factory` method. This method takes a URI string as input and returns an instance of the `Uri` class.

```
use Vdhicts\UriBuilder\Factory;

$uri = (new Factory())->build('https://example.com/path?query=string#fragment');
```

### Building the URI

[](#building-the-uri)

You can programmatically build the URI using the `Uri` class.

```
use Vdhicts\UriBuilder\Uri;

$uri = new Uri(
    scheme: 'https',
    subdomain: 'sub',
    domain: 'example',
    topLevelDomain: 'com',
);
```

Or using the fluent interface:

```
use Vdhicts\UriBuilder\Uri;

$uri = (new Uri())
    ->setScheme('https')
    ->setSubdomain('sub')
    ->setDomain('example')
    ->setTopLevelDomain('com');
```

To convert the `Uri` object to a string, you can use the `->toString()` method or cast it to a string:

```
$uri->toString(); // Outputs: https://sub.example.com
(string) $uri; // Outputs: https://sub.example.com
```

### Manipulating the URI

[](#manipulating-the-uri)

You can manipulate the URI using the `Uri` class. The `Uri` class provides methods to get and set the various components of the URI.

```
use Vdhicts\UriBuilder\Uri;

$uri = new Uri(
    scheme: 'https',
    subdomain: 'sub',
    domain: 'example',
    topLevelDomain: 'com',
);
$uri
    ->setScheme('http')
    ->setSubdomain(null)
    ->setDomain('github'); // Outputs: http://github.com
```

### Note about query parameters

[](#note-about-query-parameters)

The `Uri` class supports repeating query parameters. This means that you can add the same query parameter multiple times and it will be added to the URI as a repeating parameter.

```
use Vdhicts\HttpQueryBuilder\Parameter;
use Vdhicts\UriBuilder\Uri;

$uri = new Uri(
    scheme: 'https',
    subdomain: 'sub',
    domain: 'example',
    topLevelDomain: 'com',
    queryParameters: [
        new Parameter('param', 'value1'),
        new Parameter('param', 'value2'),
    ]
);
$uri->toString(); // Outputs: https://sub.example.com?param=value1&param=value2
```

Or adding a parameter:

```
$uri->addQueryParameter(new Parameter('param', 'value3'));
$uri->toString(); // Outputs: https://sub.example.com?param=value1&param=value2&param=value3
```

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

[](#contributing)

Found a bug or want to add a new feature? Great! There are also many other ways to make meaningful contributions such as reviewing outstanding pull requests and writing documentation. Even opening an issue for a bug you found is appreciated.

When you create a pull request, make sure it is tested, following the code standard (run `composer code-style:fix` to take care of that for you) and please create one pull request per feature. In exchange, you will be credited as contributor.

### Testing

[](#testing)

To run the tests, you can use the following command:

```
composer test
```

### Security

[](#security)

If you discover any security related issues in this or other packages of Vdhicts, please email instead of using the issue tracker.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance88

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

59d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88d23e7b707d1cfe0eea91c00590613f45e0c75cb0a3ce89354328332e5c0c02?d=identicon)[vdhicts](/maintainers/vdhicts)

---

Top Contributors

[![dvdheiden](https://avatars.githubusercontent.com/u/90568118?v=4)](https://github.com/dvdheiden "dvdheiden (6 commits)")

---

Tags

uribuilder

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[kris/laravel-form-builder

Laravel form builder - symfony like

1.7k2.2M45](/packages/kris-laravel-form-builder)[league/uri-components

URI components manipulation library

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

Functions for making sense out of URIs.

29335.2M40](/packages/sabre-uri)[gherkins/regexpbuilderphp

PHP port of thebinarysearchtree/regexpbuilderjs

1.4k163.0k1](/packages/gherkins-regexpbuilderphp)[laminas/laminas-uri

A component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)

3834.9M89](/packages/laminas-laminas-uri)[optimistdigital/nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.

243369.4k](/packages/optimistdigital-nova-menu-builder)

PHPackages © 2026

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