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

ActiveLibrary

nahid/url-factory
=================

UrlFactory is a PHP package for working with URLs

v1.0.0-a.1(3y ago)1813MITPHPPHP &gt;=8.0

Since Aug 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nahid/url-factory)[ Packagist](https://packagist.org/packages/nahid/url-factory)[ RSS](/packages/nahid-url-factory/feed)WikiDiscussions master Synced 4w ago

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

UrlFactory
==========

[](#urlfactory)

UrlFactory is a PHP package for working with URLs. Its offer you to best developer experience to manage and manipulate URLs. UrlFactory offers simple, yet powerful ways of working with query string, paths and domain.

Requirements
------------

[](#requirements)

- php &gt;= 8.0
- ext-json
- ext-intl

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

[](#installation)

UrlFactory is available on [Packagist](https://packagist.org/packages/nahid/url-factory). You can directly install it in any package by running this command bellow

```
composer require nahid/url-factory
```

Configuration
-------------

[](#configuration)

There are no extra configuration needed to run this package, but by passing config you can take more control over this package.

### Default Config

[](#default-config)

```
// use Nahid\UrlFactory\Enum;
[
    Enum::CONFIG_KEY => 'secret-key',
    Enum::CONFIG_SIGNER => MD5UrlSigner::class,
    Enum::CONFIG_PSR_CACHE_INTERFACE => null,
    Enum::CONFIG_PSR_CLIENT_INTERFACE => null,
    Enum::CONFIG_PSR_REQUEST_FACTORY_INTERFACE => null,
]
```

> you can modify it as you want and pass into UrlFactory when initialize

Syntax
------

[](#syntax)

```
new Url([string $url, [array $config]]);
```

> Both arguments of the construct are optional

Initialization
--------------

[](#initialization)

```
use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;

$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);
```

> We use `http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20` for our next examples

Example
-------

[](#example)

#### URL Extract and Fetch

[](#url-extract-and-fetch)

```
use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;

$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);

echo $url->getScheme() . "\n";
echo $url->getQuery() . "\n";
var_dump($url->getQueryParam()) . "\n";
echo $url->getPath() . "\n";
echo $url->domain()->getSubdomain() . "\n";
echo $url->domain()->getSuffix() . "\n";
echo $url->domain()->getTld() . "\n";
```

##### Output

[](#output)

```
http
q=bangladesh&page=1&limit=20
['q' => 'bangladesh', 'page '=> 1, 'limit' => 20]
private/search
app.staging
com.bd
com
```

### URL Modification

[](#url-modification)

```
use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;

$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);

$url->useSchemeHttps()
    ->usePath('query')
    ->useQueryParams(['search'=> 'dhaka'])
    ->useFragment('top')
    ->domain(function(\Nahid\UrlFactory\Domain $domain) {
        $domain->useBaseName('bing')
            ->useSuffix('co.in')
            ->useSubdomain('app');
    });

echo $url->get()
```

#### Output

[](#output-1)

```
https://app.bing.co.in/query?search=dhaka#top
```

### Signed URL

[](#signed-url)

```
use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;

$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);

$url->useSchemeHttps()
    ->usePath('query')
    ->useQueryParams(['search'=> 'dhaka'])
    ->useFragment('top')
    ->domain(function(\Nahid\UrlFactory\Domain $domain) {
        $domain->useBaseName('bing')
            ->useSuffix('co.in')
            ->useSubdomain('app');
    });

echo $url->sign(7)->get(); // Generate signed URL with 7 days validity
 
```

#### Output

[](#output-2)

```
https://app.bing.co.in/query?search=dhaka&expires=1661613403&signature=5fd3f94c145731a085f6964cb3c4d03d#top
```

API List
--------

[](#api-list)

> There are lots of API are available with this package. We'll update it ASAP

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

1358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3167309?v=4)[Nahid Bin Azhar](/maintainers/nahid)[@nahid](https://github.com/nahid)

---

Top Contributors

[![nahid](https://avatars.githubusercontent.com/u/3167309?v=4)](https://github.com/nahid "nahid (16 commits)")

---

Tags

urluriurl builderdomainurl-parserurl-factoryurl-extractor

### Embed Badge

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

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.0B3.1k](/packages/guzzlehttp-psr7)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[league/uri

URI manipulation library

1.1k206.4M276](/packages/league-uri)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[neos/flow

Flow Application Framework

862.0M449](/packages/neos-flow)

PHPackages © 2026

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