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

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

proteins/url
============

Helper object for parsing, building and handling URLs

1.0.3(6y ago)0452MITPHPPHP ^7.2

Since May 28Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (4)Used By (2)

[![](https://raw.githubusercontent.com/php-protein/docs/master/assets/protein-large.png)](https://raw.githubusercontent.com/php-protein/docs/master/assets/protein-large.png)

Protein | URL
=============

[](#protein--url)

Helper object for parsing, building and handling URLs
-----------------------------------------------------

[](#helper-object-for-parsing-building-and-handling-urls)

### Install

[](#install)

---

```
composer require proteins/url

```

Require the class via :

```
use Proteins\URL;
```

### Parse an URL

[](#parse-an-url)

---

Create a new URL object passing the existing URL as constructor parameter, that will be automatically parsed into URL components.

```
$url = new URL('https://user:pass@www.alpha.beta.com:9080/path/to/resource.html?foo=bar&another[]=2&another[]=3#frag_link');

print_r($url);
```

```
Object
(
    [scheme] => https
    [user] => user
    [pass] => pass
    [host] => www.alpha.beta.com
    [port] => 9080
    [path] => /path/to/resource.html
    [query] => Array
        (
            [foo] => bar
            [another] => Array
                (
                    [0] => 2
                    [1] => 3
                )

        )

    [fragment] => frag_link
)

```

URL class can autocast itself as the builded URL string :

```
echo "$url";
```

```
https://user:pass@www.alpha.beta.com:9080/path/to/resource.html?foo=bar&another%5B0%5D=2&another%5B1%5D=3#frag_link

```

Build or modify an URL
----------------------

[](#build-or-modify-an-url)

---

You can modify or build from scratch an URL altering the single components :

```
$url = new URL();

$url->host = 'caffeina.com';
$url->user = 'demo';

echo $url;
```

```
demo@caffeina.com

```

```
$url = new URL("ftps://test.com:9000/index.php");

$url->scheme = 'https';
$url->port = false;

echo $url;
```

```
https://test.com/index.php

```

Examples
--------

[](#examples)

---

#### Build a mailto address :

[](#build-a-mailto-address-)

```
$link = new URL('mailto://');
$link->user = 'info';
$link->host = 'myserver.com';

$link->query['subject'] = 'This is a subject';
$link->query['body'] = 'Hi! This is a test... :D';

echo $link;
```

```
mailto://info@myserver.com?subject=This+is+a+subject&body=Hi%21+This+is+a+test...+%3AD

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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

3

Last Release

2544d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[ralouphie/getallheaders

A polyfill for getallheaders.

3.8k872.8M87](/packages/ralouphie-getallheaders)[cmixin/business-day

Carbon mixin to handle business days

3944.8M8](/packages/cmixin-business-day)[loophp/phptree

An implementation of tree data structure

981.8M2](/packages/loophp-phptree)[kzykhys/php-csv-parser

Convert CSV to array (Excel style is fully suppoted!)

57264.0k5](/packages/kzykhys-php-csv-parser)[conquer/codemirror

Yii2 codemirror widget

36281.5k3](/packages/conquer-codemirror)

PHPackages © 2026

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