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

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

rayful/url
==========

A URL operation Class, including set query, get query, parse query, get domain and so on.

1.5(7y ago)12.6k12MITPHP

Since Apr 21Pushed 7y ago1 watchersCompare

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

READMEChangelog (10)DependenciesVersions (11)Used By (2)

URL
===

[](#url)

一个对URL的通用操作类。

### 安装（Composer）

[](#安装composer)

```
composer require rayful/url
```

基本用法:

```
$URL = new URL("http://abc.com/?page=1&param=a");
$URL->setQuery(["page"=>2]);
$newUrl = $URL->build();

echo $newUrl;   //will output: http://abc.com/?page=2&param=a
```

---

```
$URL = new URL("http://abc.com/?page=1&param=a");
$URL->replaceQuery(["page"=>2]);
$newUrl = $URL->build();

echo $newUrl;   //will output: http://abc.com/?page=2
```

可以全局地urlencode整条URL:

```
$URL = new URL("http://abc.com/目录1/目录2/index.php?cat=科技&rate= 非常好");
$URL->encode();
$newUrl = $URL->build();

echo $newUrl;   //http://abc.com/%E7_%AE%E5%BD_1/%E7_%AE%E5%BD_2/index.php?cat=%E7%A7_%E6__&rate=+%E9__%E5%B8%B8%E5%A5%BD
```

---

构造函数不传参,默认为改变当前URL(需要在浏览器内)的某个参数:

```
$URL = new URL();
$URL->setQuery(["page"=>2]);
$newUrl =  $URL->build();
```

快捷方式:

```
echo URL::append(['page'=>2]);
```

---

四个静态方法的调用:

```
$domain = URL::domain($url);    //url.com
$queryString = URL::queryString($url);  //query=1&query=2
$query = URL::query($url);  //['query'=>1,'query2'=>2]
$dir = URL::dir($url);  //http://url.com/doc
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% 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 ~92 days

Recently: every ~74 days

Total

10

Last Release

2888d ago

Major Versions

0.1.0 → 1.0.02016-04-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4504653?v=4)[Kingmax Yang](/maintainers/kingmaxyang)[@kingmaxyang](https://github.com/kingmaxyang)

---

Top Contributors

[![kingmaxyang](https://avatars.githubusercontent.com/u/4504653?v=4)](https://github.com/kingmaxyang "kingmaxyang (11 commits)")[![xyzhuofeng](https://avatars.githubusercontent.com/u/8706905?v=4)](https://github.com/xyzhuofeng "xyzhuofeng (3 commits)")[![Hanson](https://avatars.githubusercontent.com/u/10583423?v=4)](https://github.com/Hanson "Hanson (1 commits)")

---

Tags

urlget queryset queryencode full URLget URL domainauto get current URL

### Embed Badge

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

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

###  Alternatives

[spatie/url

Parse, build and manipulate URL's

74015.2M114](/packages/spatie-url)[league/uri-components

URI components manipulation library

31937.4M88](/packages/league-uri-components)[jbroadway/urlify

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

6757.8M75](/packages/jbroadway-urlify)[sabre/uri

Functions for making sense out of URIs.

29436.8M44](/packages/sabre-uri)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15441.7M55](/packages/spomky-labs-base64url)[misd/linkify

Converts URLs and email addresses in text into HTML links

1123.1M11](/packages/misd-linkify)

PHPackages © 2026

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