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

ActiveLibrary

folded/url
==========

URL utilities for your web app.

v0.1.1(5y ago)05[1 issues](https://github.com/folded-php/url/issues)MITPHPPHP &gt;=7.4.0

Since Sep 27Pushed 5y ago2 watchersCompare

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

READMEChangelogDependencies (3)Versions (3)Used By (0)

folded/config
=============

[](#foldedconfig)

URL utilities for your PHP web app.

[![Packagist License](https://camo.githubusercontent.com/e1fd1d7d64ffe9cf24d64862686ca98b6af6ef4890ac210efd2519183a5a0841/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666f6c6465642f75726c)](https://github.com/folded-php/url/blob/master/LICENSE) [![Packagist PHP Version Support](https://camo.githubusercontent.com/07063108500981baa901e64fafe3cbb20e7a6fdf3ead88d48456447e8cea1352/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f666f6c6465642f75726c)](https://github.com/folded-php/url/blob/master/composer.json#L14) [![Packagist Version](https://camo.githubusercontent.com/0ce7eea710c3be7c7fc5a934dc817b9e95af5a87d7c966ade5beecbd0e69bcac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f6c6465642f75726c)](https://packagist.org/packages/folded/url) [![Build Status](https://camo.githubusercontent.com/2918c628927928fd32b9b731b18177791a97421f213f9c3c86efd93499dc58e8/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f75726c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/url) [![Maintainability](https://camo.githubusercontent.com/b900cec5ba6f267ab63e2d4e2c6cdf43a7d9d4e185f3eeb1948ffdb5c2f651f1/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31393638663336616166313932343664636331362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/url/maintainability) [![TODOs](https://camo.githubusercontent.com/3d262c269fb097fe9a0456ef59ffea7686cddf3d238a004d334b6113e02e5dd9/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f75726c)](https://www.tickgit.com/browse?repo=github.com/folded-php/url)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)

About
-----

[](#about)

I created this library to have an easy way to use common URL functions like getting the current URL, in a standalone way.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration and environment utilities for your PHP web app.
- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.
- [folded/http](https://github.com/folded-php/http): HTTP utilities for your web app.
- [folded/orm](https://github.com/folded-php/orm): An ORM for you web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/session](https://github.com/folded-php/session): Session functions for your web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

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

[](#requirements)

- PHP version &gt;= 7.4.0
- Composer installed

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

[](#installation)

In your project root folder, run this command:

```
composer require folded/url
```

Examples
--------

[](#examples)

- [1. Check if the current URL matches a given URL](#1-check-if-the-current-url-matches-a-given-url)
- [2. Get the current URL](#2-get-the-current-url)
- [3. Get a query string value by key name](#3-get-a-query-string-value-by-key-name)
- [4. Get all the query strings](#4-get-all-the-query-strings)
- [5. Check if a query string is present by key name](#5-check-if-a-query-string-is-present-by-key-name)

### 1. Check if the current URL matches a given URL

[](#1-check-if-the-current-url-matches-a-given-url)

In this example, we will check if the current URL matches a given URL.

```
use function Folded\currentUrlIs;

if (currentUrlIs("/about-us")) {
  echo "We are on page /about-us";
} else {
  echo "We are somewhere else";
}
```

### 2. Get the current URL

[](#2-get-the-current-url)

In this example, we will get the current URL, including the server protocol, domain, and eventuals query strings.

```
use function Folded\getCurrentUrl;

echo getCurrentUrl(); // "https://example.com/about-us?page=1"
```

### 3. Get a query string value by key name

[](#3-get-a-query-string-value-by-key-name)

In this example, we will get the value of a query string by its key name.

```
use function Folded\getQueryString;

// Assuming we are on page https://example.com/about-us?page=1

echo getQueryString("page"); // "1"
```

If the query string is not present, the function will throw an exception. To avoid this, you can use the second parameter to provide a fallback value in case the query string is not found.

```
use function Folded\getQueryString;

echo getQueryString("page", "1");
```

### 4. Get all the query strings

[](#4-get-all-the-query-strings)

In this example, we will get all the query strings as an associative array.

```
use function Folded\getQueryStrings;

// Assuming we are on page https://example.com/about-us?page=1&view=list

$queryStrings = getQueryStrings();

foreach ($queryStrings as $key => $value) {
  echo "value of $key is $value";
}
```

### 5. Check if a query string is present by key name

[](#5-check-if-a-query-string-is-present-by-key-name)

In this example, we will check if a query string is present.

```
use function Folded\hasQueryString;

if (hasQueryString("page")) {
  echo "We can grab its value";
} else {
  echo "Do something else without it";
}
```

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

2055d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15908747?v=4)[Anwar](/maintainers/khalyomede)[@khalyomede](https://github.com/khalyomede)

---

Top Contributors

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

---

Tags

phpurl

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

PHPackages © 2026

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