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

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

keppler/url
===========

Url manipulation

v2.1.0(7y ago)15111MITPHPPHP &gt;=7.1

Since Dec 10Pushed 7y ago4 watchersCompare

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

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

Simple package to manipulate URLs
=================================

[](#simple-package-to-manipulate-urls)

[![Build Status](https://camo.githubusercontent.com/d10bcc045c57b9de5a8aa542ffe09cb3d330944018a01773ea6c4993810797b1/68747470733a2f2f7472617669732d63692e6f72672f4b6570706c6572506c2f75726c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/KepplerPl/url)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Documentation Status](https://camo.githubusercontent.com/df1370d9d2acd437ab816886cd81d1eb5c901c38d8c5673c378790a78f35dc02/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f6b6570706c6572706c2d736368656d652f62616467652f3f76657273696f6e3d6c6174657374)](https://kepplerpl-scheme.readthedocs.io/en/latest/?badge=latest)[![Maintainability](https://camo.githubusercontent.com/1569c37e9ac6bfa6c59bee631756fc9a7d01de13a3cd6f4e10b8d6e33a9082ca/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61393961383864323861643337613739646266362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/codeclimate/codeclimate/maintainability)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2563061d3ef89a49b2d5960f14f468a40220d803786b8a411624d5cec24f5478/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b6570706c6572506c2f75726c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KepplerPl/url/?branch=master)

[Read the docs documentation](https://kepplerpl-scheme.readthedocs.io/en/latest/)
---------------------------------------------------------------------------------

[](#read-the-docs-documentation)

### Installation

[](#installation)

```
composer require keppler/url

```

Quickstart
----------

[](#quickstart)

Parser and Builder
------------------

[](#parser-and-builder)

This package is split into 2 independent pieces. These pieces are also split into several other pieces.

```
The Scheme.php will be referred to as Parser in the documentation.

```

Parser
------

[](#parser)

The Parser is the entry point for parsing a url. It's immutable, meaning you cannot change it once it is created.

The scheme is split into schemes such as ftp, http, https, mailto, etc. Each scheme is used to parse a single url type, as you might have guessed.

```
require 'vendor/autoload.php';

$url =  'https://john.doe@www.example.com:123/forum/questions/answered/latest?tag=networking&order=newest#top';

$scheme = Scheme::https($url);

print_r($scheme->all());

echo $scheme->getPathBag()->first(); // forum
echo $scheme->getPathBag()->last(); // latest
echo $scheme->getPathBag()->raw(); // /forum/questions/answered/latest
echo $scheme->getPathBag()->get(1); // questions
echo $scheme->getPathBag()->has(0); // true
echo $scheme->getPathBag()->has(10); // false

var_dump($scheme->getQueryBag()->first()); // ['tag' => 'networking']

etc
```

At the time of this writing the parser supports 4 schemes: FTP, HTTPS, HTTP, and MAILTO

Builder
-------

[](#builder)

The Builder.php class is the entry point for modifying a url or simply creating one from scratch. If you choose to build from an existing url you must pass it a Parser instance with the appropriate scheme.

At the time of this writing the Builder supports 4 schemes: FTP, HTTPS, HTTP, and MAILTO

```
require 'vendor/autoload.php';

$url =  'ftp://user:password@host:123/path';

$ftpScheme = Scheme::ftp($url);
$builder = Builder::ftp($ftpScheme);

$builder->setHost('example.com')
    ->setPassword('hunter2')
    ->setPort(5);

print_r($builder->raw());
...
ftp://user:hunter2@example.com:5/path/

print_r($builder->encoded());
...
ftp://user:hunter2@example.com:5/path/to+encode/ // notice the extra +
```

Both the Parser and the Builder can be used independently.

Each supported scheme can also be used independently without the Builder or the Parser. Examples bellow.

Independent usage
-----------------

[](#independent-usage)

Assuming you don't want to use the Parser/Builder classes directly you can choose not to.

Each scheme supported can be used independently of the Parser/Builder.

```
$ftpUrl = 'ftp://user:password@host:123/path';

$ftpImmutable = new FtpImmutable($ftpUrl);

echo $ftpImmutable->raw();

$ftpBuilder = new FtpBuilder();

$ftpBuilder->setHost('host')
    ->setPassword('hunter2')
    ->setPort(987)
    ->setUser('hunter');

$ftpBuilder->getPathBag()
    ->set(0, 'path')
    ->set(1, 'new path');

echo $ftpBuilder->raw(); // ftp://hunter:hunter2@host:987/path/new path/

echo $ftpBuilder->encoded(); // ftp://hunter:hunter2@host:987/path/new+path/
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 94.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

Every ~4 days

Total

3

Last Release

2706d ago

Major Versions

v1.0.0 → v2.0.02018-12-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8ef45de943d2029ba8d3702e56b0a2536dfc0099cdde172ceceae51080e4e06?d=identicon)[Keppler](/maintainers/Keppler)

---

Top Contributors

[![andrei-popa88](https://avatars.githubusercontent.com/u/8496487?v=4)](https://github.com/andrei-popa88 "andrei-popa88 (98 commits)")[![DavidGoodwin](https://avatars.githubusercontent.com/u/203929?v=4)](https://github.com/DavidGoodwin "DavidGoodwin (3 commits)")[![module17](https://avatars.githubusercontent.com/u/157851?v=4)](https://github.com/module17 "module17 (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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