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

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

hoangphison/url
===============

Parse, build and manipulate URL's

1.0.0(8y ago)0941MITPHPPHP &gt;=5.6

Since Sep 26Pushed 8y agoCompare

[ Source](https://github.com/hoangphison/url)[ Packagist](https://packagist.org/packages/hoangphison/url)[ Docs](https://github.com/hoangphison/url)[ RSS](/packages/hoangphison-url/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (5)Used By (1)

Parse, build and manipulate URL's
=================================

[](#parse-build-and-manipulate-urls)

[![Build Status](https://camo.githubusercontent.com/31756cb7f0367d5d08e3e0da6ac52322dbf09feb31c28171ebc8b7a4df9b41e5/68747470733a2f2f7472617669732d63692e6f72672f686f616e67706869736f6e2f75726c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hoangphison/url)[![StyleCI](https://camo.githubusercontent.com/5a02e4d0089b131d46c4e09c5b70d139d7ff2f281749365f4bfce897cffad585/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131313930303739332f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/111900793)

A simple package to deal with URL's in your applications.

Retrieve parts of the URL:

```
$url = Url::fromString('https://spatie.be/opensource');

echo $url->getScheme(); // 'https'
echo $url->getHost(); // 'spatie.be'
echo $url->getPath(); // '/opensource'
```

Transform any part of the URL (the `Url` class is immutable):

```
$url = Url::fromString('https://spatie.be/opensource');

echo $url->withHost('github.com')->withPath('spatie');
// 'https://github.com/spatie'
```

Retrieve and transform query parameters:

```
$url = Url::fromString('https://spatie.be/opensource?utm_source=github&utm_campaign=pacakges');

echo $url->getQuery(); // 'utm_source=github&utm_campaign=pacakges'
echo $url->getQueryParameter('utm_source'); // 'github'
echo $url->withoutQueryParameter('utm_campaign'); // 'https://spatie.be/opensource?utm_source=github'
```

Retrieve path segments:

```
$url = Url::fromString('https://spatie.be/opensource/laravel');

echo $url->getSegment(1); // 'opensource'
echo $url->getSegment(2); // 'laravel'
```

Implements PSR-7's `UriInterface` interface:

```
class Url implements UriInterface { /* ... */ }
```

The [`league/uri`](https://github.com/thephpleague/uri) is a more powerful package than this one. The main reason this package exists, is because the alternatives requires non-standard php extensions. If you're dealing with special character encodings or need bulletproof validation, you're definitely better off using `league/uri`.

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

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

[](#installation)

You can install the package via composer:

```
composer require hoangphison/url
```

Usage
-----

[](#usage)

Usage is pretty straightforward. Check out the code examples at the top of this readme.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 54.2% 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

3091d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/516402738c16a9d7707d638d399b4b2c40cfc27776e8d5e25eea26ee58265b9f?d=identicon)[sonhp](/maintainers/sonhp)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (26 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (13 commits)")[![hoangphison](https://avatars.githubusercontent.com/u/9270621?v=4)](https://github.com/hoangphison "hoangphison (5 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")[![bmitch](https://avatars.githubusercontent.com/u/4009957?v=4)](https://github.com/bmitch "bmitch (1 commits)")[![srmklive](https://avatars.githubusercontent.com/u/839335?v=4)](https://github.com/srmklive "srmklive (1 commits)")

---

Tags

urlspatiehoangphison

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/url

Parse, build and manipulate URL's

73914.3M97](/packages/spatie-url)[spatie/laravel-package-tools

Tools for creating Laravel packages

935125.5M7.0k](/packages/spatie-laravel-package-tools)[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/macroable

A trait to dynamically add methods to a class

72659.6M64](/packages/spatie-macroable)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k17.1M59](/packages/spatie-regex)[spatie/enum

PHP Enums

84429.1M68](/packages/spatie-enum)

PHPackages © 2026

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