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

ActiveLibrary

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

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

1.5(7y ago)02.6k1MITPHP

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 today

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

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

33

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

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

2794d ago

Major Versions

0.1.0 → 1.0.02016-04-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/1412a217896637f39725a032a9fc9c77c8feeb843daa3b5b696b8eb0fef53a94?d=identicon)[kingmaxyang](/maintainers/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

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k997.0M2.7k](/packages/guzzlehttp-psr7)[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k775.6M1.6k](/packages/symfony-routing)[league/uri

URI manipulation library

1.1k196.3M232](/packages/league-uri)[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

537194.9M19](/packages/league-uri-interfaces)[spatie/url

Parse, build and manipulate URL's

74013.9M76](/packages/spatie-url)[nette/http

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

50318.8M497](/packages/nette-http)

PHPackages © 2026

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