PHPackages                             decodelabs/singularity - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. decodelabs/singularity

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

decodelabs/singularity
======================

Consolidated URI parsing and resolving

v0.4.2(9mo ago)13.0k2MITPHPPHP ^8.4CI passing

Since Oct 29Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/singularity)[ Packagist](https://packagist.org/packages/decodelabs/singularity)[ RSS](/packages/decodelabs-singularity/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (22)Used By (2)

Singularity
===========

[](#singularity)

[![PHP from Packagist](https://camo.githubusercontent.com/73fe3f319cec763c7f001312deb40ec0124e8378744d89e1791bdec2dc7a4b5c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f73696e67756c61726974793f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/singularity)[![Latest Version](https://camo.githubusercontent.com/ef46c7a6591da0acec0e83d4e633ad7b9e5dadaad7949019c789764941d385d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f73696e67756c61726974792e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/singularity)[![Total Downloads](https://camo.githubusercontent.com/d407a0b367930c4da831413c77973e02be69b3fd4c0c13cf26868d611ba833ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f73696e67756c61726974792e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/singularity)[![GitHub Workflow Status](https://camo.githubusercontent.com/688cb979fd2751b683192d7ea51225c9399643eb941d6fb30bca16db43a01f84/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f73696e67756c61726974792f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/singularity/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/c77e0c78ab033adc53e4830ac9a4a8da720c8a65c28fd286000ff192571d3191/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f73696e67756c61726974793f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/singularity)

### Consolidated URI parsing and resolving

[](#consolidated-uri-parsing-and-resolving)

Singularity provides a unified interface for parsing and resolving URIs, PSR-7 URLs and file paths.

---

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

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/singularity
```

Usage
-----

[](#usage)

Parse and normalize URIs:

```
use DecodeLabs\Singularity;

dd(
    // ::uri() will parse any valid URI
    Singularity::uri('mailto:info@example.com'),

    // ::url() will parse any valid URL
    Singularity::url('http://user:pass@www.example.com:8080/resource/page.html?param1=value1&param2=value2#section1'),
    Singularity::url('ftp://ftp.example.com/files/document.pdf'),
    Singularity::url('mailto:user@example.com?subject=Hello&body=Hi%20there')->getEmailAddress(),
    Singularity::url('tel:+1-816-555-1212'),

    // ::urn() will parse any valid URN
    Singularity::urn('urn:isbn:0-486-27557-4'),
    Singularity::urn('urn:ietf:rfc:3986')->getNamespace(), // ietf
    Singularity::urn('urn:oid:2.16.840')->getIdentifier(), // 2.16.840
);
```

Parse query strings to `Tree`:

```
use DecodeLabs\Singularity;

$url = Singularity::uri('http://www.example.com?param1=value1&param2=value2');
$tree = $url->parseQuery();
echo $tree->param2->as('string'); // value2

// Update query
$newUrl = $url->withQuery(function($tree, $url) {
    $tree->param2 = 'newValue2';
    $tree->param3 = 'value3';
    return $tree;
});
```

Parse and normalize file paths:

```
use DecodeLabs\Singularity;

dd(
    // ::path() will parse any valid file path
    Singularity::path('/path/to/file.txt'),
    Singularity::path('C:\path\to\file.txt'),
    Singularity::path('file:///path/to/file.txt'),
    Singularity::path('file://C:/path/to/file.txt'),

    // ::canonicalPath() will parse any valid file path and normalize it
    Singularity::canonicalPath('/path/to/inner/./directory/../../file.txt'), // /path/to/file.txt
);

$url = Singularity::uri('http://www.example.com?param1=value1&param2=value2');
$url->withPath(function($path) {
    $path->setFileName('file.txt');
    return $path;
});
```

Licensing
---------

[](#licensing)

Singularity is licensed under the proprietary License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance76

Regular maintenance activity

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~29 days

Total

20

Last Release

273d ago

PHP version history (3 changes)v0.1.0PHP ^8.0

v0.2.6PHP ^8.1

v0.3.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (98 commits)")

---

Tags

phpuriurl

### Embed Badge

![Health badge](/badges/decodelabs-singularity/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)

PHPackages © 2026

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