PHPackages                             modularr/uri - 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. modularr/uri

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

modularr/uri
============

Single Responisibilty Uri Library

1.0.0(5y ago)342PHP

Since Sep 16Pushed 4y agoCompare

[ Source](https://github.com/Modularr/uri)[ Packagist](https://packagist.org/packages/modularr/uri)[ RSS](/packages/modularr-uri/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

URI Class
=========

[](#uri-class)

[![Latest Version](https://camo.githubusercontent.com/8f1fe7fc08c27cc9570b84c594f88511b012ac680c51e7df88d05a99798ec22d/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f64756c6172722f7572692e7376673f7374796c653d666c6174)](https://packagist.org/packages/Modularr/uri)[![Software License](https://camo.githubusercontent.com/e1591610e67838773248bbc72629e3f476fdad6fae0b5a6e1463dcbe2a1f76e8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d554e4c4943454e53452d626c75652e737667)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/8bbedf1ba4d620adb44cbe62b0d665249dc2de37eb8356cf53a270cce5fc9238/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f64756c6172722f7572692e7376673f7374796c653d666c6174)](https://packagist.org/packages/Modularr/uri)

The URI Class provides functions that help you retrieve information from your URI strings. If you use URI routing, you can also retrieve information about the re-routed segments.

This is a library similar to [CodeIgniter](http://www.codeigniter.com) [URI Class](http://www.codeigniter.com/userguide2/libraries/uri.html), simply Instantiate the Class.

#### Install &amp; Usage

[](#install--usage)

`composer require modularr/uri`

```
$uri = new URI('/folder_path');
```

$uri = new URI($folder=null);
-----------------------------

[](#uri--new-urifoldernull)

Folder is optional, but necessary if your project is in a subfolder.

$uri-&gt;segment(n)
-------------------

[](#uri-segmentn)

Permits you to retrieve a specific segment. Where n is the segment number you wish to retrieve. Segments are numbered from left to right. For example, if your full URL is this:

The segment numbers would be this:

`http://example.com/index.php/news/local/metro/crime_is_up`

1. news
2. local
3. metro
4. crime\_is\_up

By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of failure:

```
$product_id = $uri->segment(3, 0);
```

It helps avoid having to write code like this:

```
if (empty($uri->segment(3)))
{
    $product_id = 0; # if segment is empty
}
else
{
    $product_id = $uri->segment(3); # get the segment
}
```

$uri-&gt;uri\_string()
----------------------

[](#uri-uri_string)

Returns a string with the complete URI. For example, if this is your full URL:

`http://example.com/index.php/news/local/345`

The function would return this:

`/news/local/345`

$uri-&gt;total\_segments()
--------------------------

[](#uri-total_segments)

Returns the total number of segments.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

2061d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpsegment-numberssegmentsuriuri-parseruri-stringsurlurihelperlibrary

### Embed Badge

![Health badge](/badges/modularr-uri/health.svg)

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

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M66](/packages/league-uri-components)[rowbot/url

A WHATWG URL spec compliant URL parser for working with URLs and their query strings.

19648.2k4](/packages/rowbot-url)

PHPackages © 2026

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