PHPackages                             achais/shorturl - 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. achais/shorturl

ActiveLibrary

achais/shorturl
===============

一键生成和还原短链接的 PHP 扩展包

v1.0(7y ago)141961MITPHPPHP &gt;=5.6CI failing

Since Apr 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/achais/shorturl)[ Packagist](https://packagist.org/packages/achais/shorturl)[ RSS](/packages/achais-shorturl/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

 ShortUrl
==========

[](#-shorturl-)

一键生成和还原短链接的 PHP 扩展包，我们支持多平台了哦!

[![Build Status](https://camo.githubusercontent.com/45adfca9c58b883cf077cf719d5215c1bbe438905611717809ddb9f2633652af/68747470733a2f2f7472617669732d63692e6f72672f6163686169732f73686f727475726c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/achais/shorturl)[![StyleCI build status](https://camo.githubusercontent.com/25d2be32f2bd83cf0b303eb8ed826b52d4de087d1eeacbd5377011fb1abaf28f/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137393633303434382f736869656c64)](https://camo.githubusercontent.com/25d2be32f2bd83cf0b303eb8ed826b52d4de087d1eeacbd5377011fb1abaf28f/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137393633303434382f736869656c64)

特点
--

[](#特点)

1. 支持目前市面多家服务商
2. 一套写法兼容所有平台
3. 简单配置即可灵活增减服务商
4. 内置多种服务商轮询策略、支持自定义轮询策略
5. 统一的返回值格式，便于日志与监控
6. 自动轮询选择可用的服务商
7. 更多等你去发现与改进...

平台支持
----

[](#平台支持)

- [百度 短链](https://dwz.cn/)
- [微博 短链](https://open.weibo.com/wiki/%E5%BE%AE%E5%8D%9AAPI#.E7.9F.AD.E9.93.BE)（官方功能已下线）

环境要求
----

[](#环境要求)

- PHP &gt;= 5.6

安装
--

[](#安装)

```
$ composer require achais/shorturl -vvv
```

使用
--

[](#使用)

```
use Achais\ShortUrl\ShortUrl;

$config = [
    // HTTP 请求的超时时间（秒）
    'timeout' => 5.0,

    // 默认使用配置
    'default' => [
        // 网关调用策略，默认：顺序调用
        'strategy' => \Achais\ShortUrl\Strategies\OrderStrategy::class,

        // 默认可用的发送网关
        'gateways' => [
            'baidu',
        ],
    ],

    // 可用的网关配置
    'gateways' => [
        'baidu' => [
            'token' => '44712d2fdaaa48d0a717866e9a******',
        ],
        'weibo' => [
            'source' => '1771******',
        ],
        //...
    ],
];

$shortUrl = new ShortUrl($config);

// 长链接 -> 短链接
$long_url = 'https://www.achais.com';
$result = $shortUrl->shorten($long_url);
print_r($result);

// 短链接 -> 长链接
$short_url = 'https://dwz.cn/ZzVmHQZa';
$result = $shortUrl->expand($short_url);
var_dump($result);
```

各平台配置说明
-------

[](#各平台配置说明)

### [百度 短链](https://dwz.cn/)

[](#百度-短链)

```
'baidu' => [
    'token' => ''
],
```

### [微博 短链](https://open.weibo.com/wiki/%E5%BE%AE%E5%8D%9AAPI#.E7.9F.AD.E9.93.BE)

[](#微博-短链)

```
'weibo' => [
    'source' => ''
],
```

贡献
--

[](#贡献)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/achais/shorturl/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/achais/shorturl/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

2596d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7384071?v=4)[起风](/maintainers/achais)[@achais](https://github.com/achais)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/achais-shorturl/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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