PHPackages                             phpmask/purl - 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. phpmask/purl

ActiveLibrary

phpmask/purl
============

URL Manipulation for PHP 5.3

v1.0.0(2y ago)052MITPHPPHP ^7.2

Since Jun 15Pushed 2y agoCompare

[ Source](https://github.com/phpmask/purl)[ Packagist](https://packagist.org/packages/phpmask/purl)[ Docs](http://github.com/jwage/purl)[ RSS](/packages/phpmask-purl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Purl
====

[](#purl)

Purl is a simple Object Oriented URL manipulation library for PHP 7.2+

[![Build Status](https://camo.githubusercontent.com/8ebe2b2245ca3630f0350fa32fe071b2901cd15d2c4e443570f90bf9418fb7d7/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6a776167652f7075726c2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/jwage/purl)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/0238d58527f25483dd1517aea4ee6d9331dc4a54c6e061f3da94f7519de01b9b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a776167652f7075726c2f6261646765732f7175616c6974792d73636f72652e706e673f733d37653065316434623564376636626536316133636438303464626135353661306534643131343164)](https://scrutinizer-ci.com/g/jwage/purl/)[![Code Coverage](https://camo.githubusercontent.com/a582a02954c0e52c3e51bc50d53d0bd34794435c9d0f2b8fd5949f3c53b687f5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a776167652f7075726c2f6261646765732f636f7665726167652e706e673f733d61303233333262633464366133326466333137316632626137313465343538336137306330313534)](https://scrutinizer-ci.com/g/jwage/purl/)[![Latest Stable Version](https://camo.githubusercontent.com/6866ceb85603562994aab38c7a989a0699852cbe52f9e15bce7a6a00ee188727/68747470733a2f2f706f7365722e707567782e6f72672f6a776167652f7075726c2f762f737461626c652e706e67)](https://packagist.org/packages/jwage/purl)[![Total Downloads](https://camo.githubusercontent.com/5ead75613460958a6e3d25154292f754516dda6de6b384bd4dfecbf7e7fbc4b4/68747470733a2f2f706f7365722e707567782e6f72672f6a776167652f7075726c2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/jwage/purl)

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

[](#installation)

The suggested installation method is via [composer](https://getcomposer.org/):

```
composer require jwage/purl
```

Using Purl
----------

[](#using-purl)

Creating Url instances is easy. You can specify the URL you want, or just use the current URL:

```
use Purl\Url;

$url = new Url('http://jwage.com');
$currentUrl = Url::fromCurrent();
```

You can chain methods together after creating the `Url` like this:

```
$url = (new Url('http://jwage.com'))
    ->set('scheme', 'https')
    ->set('port', '443')
    ->set('user', 'jwage')
    ->set('pass', 'password')
    ->set('path', 'about/me')
    ->set('query', 'param1=value1&param2=value2')
    ->set('fragment', 'about/me?param1=value1&param2=value2');

echo $url->getUrl(); // https://jwage:password@jwage.com:443/about/me?param1=value1&param2=value2#about/me?param1=value1&param2=value2

// $url->path becomes instanceof Purl\Path
// $url->query becomes instanceof Purl\Query
// $url->fragment becomes instanceof Purl\Fragment
```

### Path Manipulation

[](#path-manipulation)

```
$url = new Url('http://jwage.com');

// add path segments one at a time
$url->path->add('about')->add('me');

// set the path data from a string
$url->path = 'about/me/another_segment'; // $url->path becomes instanceof Purl\Path

// get the path segments
print_r($url->path->getData()); // array('about', 'me', 'another_segment')
```

### Query Manipulation

[](#query-manipulation)

```
$url = new Url('http://jwage.com');
$url->query->set('param1', 'value1');
$url->query->set('param2', 'value2');

echo $url->query; // param1=value1&param2=value2
echo $url; // http://jwage.com?param1=value1&param2=value2

// set the query data from an array
$url->query->setData([
    'param1' => 'value1',
    'param2' => 'value2'
]);

// set the query data from a string
$url->query = 'param1=value1&param2=value2'; // $url->query becomes instanceof Purl\Query
print_r($url->query->getData()); //array('param1' => 'value1', 'param2' => 'value2')
```

### Fragment Manipulation

[](#fragment-manipulation)

```
$url = new Url('http://jwage.com');
$url->fragment = 'about/me?param1=value1&param2=value2'; // $url->fragment becomes instanceof Purl\Fragment
```

A Fragment is made of a path and a query and comes after the hashmark (#).

```
echo $url->fragment->path; // about/me
echo $url->fragment->query; // param1=value1&param2=value2
echo $url; // http://jwage.com#about/me?param1=value1&param2=value2
```

### Extract URLs

[](#extract-urls)

You can easily extract urls from a string of text using the `extract` method:

```
$string = 'some text http://google.com http://jwage.com';
$urls = Url::extract($string);

echo $urls[0]; // http://google.com/
echo $urls[1]; // http://jwage.com/
```

### Join URLs

[](#join-urls)

You can easily join two URLs together using Purl:

```
$url = new Url('http://jwage.com/about?param=value#fragment');
$url->join('http://about.me/jwage');

echo $url; // http://about.me/jwage?param=value#fragment
```

Or if you have another `Url` object already:

```
$url1 = new Url('http://jwage.com/about?param=value#fragment');
$url2 = new Url('http://about.me/jwage');
$url1->join($url2);

echo $url1; // http://about.me/jwage?param=value#fragment
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

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

1069d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9dc9a727c43c7cbc9c4dca124f2ee49080b37e3f642071d437f24e78ba3740cf?d=identicon)[phpmask](/maintainers/phpmask)

---

Top Contributors

[![jwage](https://avatars.githubusercontent.com/u/97422?v=4)](https://github.com/jwage "jwage (88 commits)")[![jeremykendall](https://avatars.githubusercontent.com/u/288613?v=4)](https://github.com/jeremykendall "jeremykendall (22 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (3 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")[![paulredmond](https://avatars.githubusercontent.com/u/177773?v=4)](https://github.com/paulredmond "paulredmond (2 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (2 commits)")[![acidvertigo](https://avatars.githubusercontent.com/u/809397?v=4)](https://github.com/acidvertigo "acidvertigo (2 commits)")[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (1 commits)")[![longchiwen](https://avatars.githubusercontent.com/u/1258717?v=4)](https://github.com/longchiwen "longchiwen (1 commits)")[![mmcev106](https://avatars.githubusercontent.com/u/2627854?v=4)](https://github.com/mmcev106 "mmcev106 (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![rcmachado](https://avatars.githubusercontent.com/u/141832?v=4)](https://github.com/rcmachado "rcmachado (1 commits)")[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (1 commits)")[![arnaud-lb](https://avatars.githubusercontent.com/u/365207?v=4)](https://github.com/arnaud-lb "arnaud-lb (1 commits)")[![atijust](https://avatars.githubusercontent.com/u/1526990?v=4)](https://github.com/atijust "atijust (1 commits)")[![b-alidra](https://avatars.githubusercontent.com/u/372249?v=4)](https://github.com/b-alidra "b-alidra (1 commits)")[![Cosmologist](https://avatars.githubusercontent.com/u/966525?v=4)](https://github.com/Cosmologist "Cosmologist (1 commits)")[![deminy](https://avatars.githubusercontent.com/u/865547?v=4)](https://github.com/deminy "deminy (1 commits)")

---

Tags

urlmanipulation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpmask-purl/health.svg)

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

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M711](/packages/doctrine-inflector)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[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)[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k38.3M217](/packages/liip-imagine-bundle)

PHPackages © 2026

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