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

ActiveLibrary

simplon/url
===========

Simple URL

0.6.1(6y ago)115.5k12MITPHPPHP &gt;=7.2CI failing

Since Nov 17Pushed 6y agoCompare

[ Source](https://github.com/fightbulc/simplon_url)[ Packagist](https://packagist.org/packages/simplon/url)[ Docs](https://github.com/fightbulc/simplon_url)[ RSS](/packages/simplon-url/feed)WikiDiscussions master Synced 2mo ago

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

```
     _                 _                          _
 ___(_)_ __ ___  _ __ | | ___  _ __    _   _ _ __| |
/ __| | '_ ` _ \| '_ \| |/ _ \| '_ \  | | | | '__| |
\__ \ | | | | | | |_) | | (_) | | | | | |_| | |  | |
|___/_|_| |_| |_| .__/|_|\___/|_| |_|  \__,_|_|  |_|
                |_|

```

Simplon Url
===========

[](#simplon-url)

Straight forward URL parser and builder.

---

Requirements
============

[](#requirements)

- PHP7.2+

Parsing
=======

[](#parsing)

### HTTP and alike

[](#http-and-alike)

Parse URLs is as simple as the following example:

```
$url = new Url(
    'http://foo.bar.com/en/test/challenge?utm_source=source&utm_campaign=campaign&utm_medium=medium#hello-world'
);

$url->getProtocol(); // http
$url->getHost(); // foo.bar.com
$url->getSubDomain(); // foo
$url->getDomain(); // bar
$url->getTopLevelDomain(); // com
$url->getPath(); // /en/test/challenge
$url->getAllQueryParams(); // ['utm_source' => 'source', ...]
$url->getQueryParam('utm_source'); // source
$url->getPathSegment(1); // en
$url->getPathSegment(2); // test
$url->getFragment(); // hello-world
```

### FTP and alike

[](#ftp-and-alike)

```
$url = new Url(
    'ftp://peter:sunny@foobar.com:21'
);

$url->getUser(); // peter
$url->getPass(); // sunny
$url->getPort(); // 21
```

---

Building / Manipulating
=======================

[](#building--manipulating)

You can build a URL from scratch or manipulate from an existing one.

### Building a new one

[](#building-a-new-one)

```
$url = (new Url())
    ->withProtocol('https')
    ->withHost('dear-johnny.io')
    ->withPath('/foo/bar')
    ->withQueryParam('sun', 'is-shining')
    ->withQueryParam('training', 'yes')
    ->withFragment('hello-world');

echo $url; // https://dear-johnny.io/foo/bar?sun=is-shining&training=yes#hello-world
```

### Manipulate an existing one

[](#manipulate-an-existing-one)

```
$url = new Url(
    'https://us.dear-johnny.io/foo/bar?sun=is-shining&training=yes#hello-world'
);

$url
    ->withoutSubDomain()
    ->withTopLevelDomain('com')
    ->withPathSegment(1, 'hoo')
    ->withPrefixPath('/en')
    ->withTrailPath('/much/more')
    ->withoutQueryParam('training')
    ->withQueryParam('sun', 'off')
    ->withoutFragment();

echo $url; // https://dear-johnny.com/en/hoo/bar/much/more?sun=off
```

### Working with path placeholders

[](#working-with-path-placeholders)

Path placeholders work for the following path manipulations. Placeholders are optional and work as following:

```
//
// withPath
//

$route = '/say/{message}';
$url = new Url('https://foobar.io');
$url->withPath($route, ['message' => 'hello']);
echo $url; // https://foobar.io/say/hello

//
// withPrefixPath
//

$route = '/hello/{message}';
$url = new Url('https://foobar.io/bob');
$url->withPrefixPath($route, ['message' => 'there']);
echo $url; // https://foobar.io/hello/there/bob

//
// withTrailPath
//

$route = '/got/{count}/{item}';
$url = new Url('https://foobar.io/bob');
$url->withTrailPath($route, ['count' => 'five', 'item' => 'cars']);
echo $url; // https://foobar.io/bob/got/five/cars
```

---

License
=======

[](#license)

Simplon Url is freely distributable under the terms of the MIT license.

Copyright (c) 2017 Tino Ehrich ()

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

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Recently: every ~225 days

Total

24

Last Release

2219d ago

PHP version history (3 changes)0.1.0PHP &gt;=7.0

0.4.0PHP &gt;=7.1

0.6.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ac00878c8c7a883b6b5cbd697b82838cad15e294e5a52d8c4a173bd664d6b4d?d=identicon)[fightbulc](/maintainers/fightbulc)

---

Tags

accesschangecreateurlurl-parsingurlmanipulationparsebuildcreate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.0B3.2k](/packages/guzzlehttp-psr7)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[league/uri

URI manipulation library

1.1k206.4M277](/packages/league-uri)[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

538204.9M23](/packages/league-uri-interfaces)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15439.5M49](/packages/spomky-labs-base64url)[marcelgwerder/laravel-api-handler

Package providing helper functions for a Laravel REST-API

16092.6k](/packages/marcelgwerder-laravel-api-handler)

PHPackages © 2026

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