PHPackages                             donnikitos/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. donnikitos/url

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

donnikitos/url
==============

PHP URL class to parse, construct, normalize, and encode URLs - but just like in JavaScript

v1.0.0(2y ago)195MITPHPPHP &gt;=7.0

Since Aug 15Pushed 2mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

URL
===

[](#url)

The URL class is used to parse, construct, normalize, and encode URLs. It works by providing properties which allow you to easily read and modify the components of a URL.

You normally create a new URL object by specifying the URL as a string when calling its constructor, or by providing a relative URL and a base URL. You can then easily read the parsed components of the URL or make changes to the URL.

### Instance properties

[](#instance-properties)

##### `hash`

[](#hash)

A string containing the fragment identifier of the URL.

##### `host`

[](#host)

A string containing the domain (that is the hostname) followed by (if a port was specified) a ':' and the port of the URL.

##### `hostname`

[](#hostname)

A string containing the domain of the URL.

##### `href`

[](#href)

A stringifier that returns a string containing the whole URL.

##### `origin`

[](#origin)

Returns a string containing the origin of the URL, that is its scheme, its domain and its port.

##### `password`

[](#password)

A string containing the password specified before the domain name.

##### `pathname`

[](#pathname)

A string containing an initial '/' followed by the path of the URL, not including the query string or fragment.

##### `port`

[](#port)

A string containing the port number of the URL.

##### `protocol`

[](#protocol)

A string containing the protocol scheme of the URL.

##### `search`

[](#search)

A string indicating the URL's parameter string; if any parameters are provided, this string includes all of them.

##### `searchParams`

[](#searchparams)

A URLSearchParams object which can be used to access the individual query parameters found in search.

##### `username`

[](#username)

A string containing the username specified before the domain name.

### Instance methods

[](#instance-methods)

##### `toString()`

[](#tostring)

Returns a string containing the whole URL. It is a synonym for URL.href, though it can't be used to modify the value.

##### `toJSON()`

[](#tojson)

Returns a JSON string containing a serialized version of the URL object.

URLSearchParams
===============

[](#urlsearchparams)

The URLSearchParams interface defines utility methods to work with the query string of a URL.

### Instance properties

[](#instance-properties-1)

##### `size`

[](#size)

Indicates the total number of search parameter entries.

### Instance methods

[](#instance-methods-1)

##### `append(string $name, string | int | bool $value)`

[](#appendstring-name-string--int--bool-value)

Appends a specified key/value pair as a new search parameter.

##### `delete(string $name, null | string | int | bool $value = null)`

[](#deletestring-name-null--string--int--bool-value--null)

Deletes search parameters that match a name, and optional value, from the list of all search parameters.

##### `entries()`

[](#entries)

Returns an iterator allowing iteration through all key/value pairs contained in this object in the same order as they appear in the query string.

##### `get(string $name)`

[](#getstring-name)

Returns the first value associated with the given search parameter.

##### `has(string $name)`

[](#hasstring-name)

Returns a boolean value indicating if a given parameter, or parameter and value pair, exists.

##### `keys()`

[](#keys)

Returns an iterator allowing iteration through all keys of the key/value pairs contained in this object.

##### `set(string $name, string | int | bool $value)`

[](#setstring-name-string--int--bool-value)

Sets the value associated with a given search parameter to the given value. If there are several values, the others are deleted.

##### `toString()`

[](#tostring-1)

Returns a string containing a query string suitable for use in a URL.

##### `values()`

[](#values)

Returns an iterator allowing iteration through all values of the key/value pairs contained in this object.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance56

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

1006d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

javascriptphpphp-javascripturlurl-engineurl-modifierurl-parserurlparse\_urlURLSearchParamsURL-APIURLSearchParams-APIurl processingnormalize urlencode url

### Embed Badge

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

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

###  Alternatives

[spatie/url

Parse, build and manipulate URL's

73914.3M97](/packages/spatie-url)[jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

6737.4M62](/packages/jbroadway-urlify)[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[sabre/uri

Functions for making sense out of URIs.

29335.2M40](/packages/sabre-uri)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15439.5M49](/packages/spomky-labs-base64url)[opis/uri

Build, parse and validate URIs and URI-templates

1620.8M6](/packages/opis-uri)

PHPackages © 2026

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