PHPackages                             yymou/slink - 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. yymou/slink

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

yymou/slink
===========

Generate short url | PHP实现轻量稳定且易用短链接短网址服务

1.0.13(3y ago)163279MITPHPPHP &gt;=7.1.0

Since Sep 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yymou/Slink)[ Packagist](https://packagist.org/packages/yymou/slink)[ RSS](/packages/yymou-slink/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (7)Dependencies (1)Versions (19)Used By (0)

Slink
=====

[](#slink)

利用redis实现的常用的短链服务, 支持redis一主多从配置, 速度快且运行稳定(建议开启redis持久化), 能满足亿级别的链接转化需求. 底层使用redis发号器递增转换成62进制,但根据简单算法实现了短链接非递增返回. 解析短链依托redis,速度快.

#### 使用:

[](#使用)

- 1 使用composer引入

    - 执行 `composer require yymou/slink`
    - 项目中引入composer `require 'vendor/autoload.php';`
- 2 项目中使用

    - 设置redis连接 1 : 如果已有redis示例, 则直接传入即可 ```
           Slink\App::getInstance()->setRedisConnect(redisObj)

        ```
    - 设置redis连接 2 : 通用配置 &gt; 读写分离配置
        - 通用配置 :
            - ```
                  Slink\App::getInstance()->setCommonRedis([
                     'hostname' => '127.0.0.1',
                     'password' => '',
                     'port' => '6379',
                     'timeout' => '5',
                     'database' => '0'
                 ]);

                ```
        - 读写分离配置 :
            - ```
                Slink\App::getInstance()->setClusterRedis([
                     'write' => [
                         'hostname' => '127.0.0.2',
                     ],
                     //支持设置多个读库
                     'read' => [
                         [
                             'hostname' => '127.0.0.3',
                         ],
                         [
                             'hostname' => '127.0.0.4',
                         ]
                     ],
                 ]);

                ```

        > 如使用读写分离配置,则不可设置通用配置,否则不生效;
    - 设置redis前缀(可选) ```
        Slink\App::getInstance()->setRedisPrefix('slink:test');

        ```

        > 如不设置则默认前缀为slink
    - 设置原始链接缓存过期时间(可选) (如设置一天则 24小时内同样的链接会返回相同的短链) 单位为秒 ```
        Slink\App::getInstance()->setOlinkCacheTtl(86400*2);

        ```

        > 如不设置则默认缓存时间为86400秒
    - 设置返回短链长度(可选) 生成短链长度 推荐是7位 一旦项目启动禁止修改该值 7位生成的数量我62的*6*次方 最小为4 ```
        Slink\App::getInstance()->setSlinkLen(7);

        ```
    - **生成短链接实例**```
            $slink = Slink\App::getInstance()->getSlink('https://www.baidu.com');

        ```
    - **短连接解析**

    ```
         $olink =Slink\App::getInstance()->getOlink('gikmor1');

    ```

    > 项目通过短链获取原始链接后,可通过302定向原始的url地址

> 有意见或问题可以随时联系我交流哈 qq:875167485 WeChat:yangmeng6036

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

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

Recently: every ~0 days

Total

15

Last Release

1366d ago

PHP version history (2 changes)v1.0.x-devPHP &gt;=7.0.0

1.0.3PHP &gt;=7.1.0

### Community

Maintainers

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

---

Top Contributors

[![yymou](https://avatars.githubusercontent.com/u/24714965?v=4)](https://github.com/yymou "yymou (25 commits)")

---

Tags

phpshortlinkslinkshorturl slink php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yymou-slink/health.svg)

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

###  Alternatives

[michaldudek/foundation

A set of useful PHP classes.

13111.9k13](/packages/michaldudek-foundation)[thunder/thunder-project

Project template for Thunder projects with composer

1039.4k](/packages/thunder-thunder-project)[codefog/contao-instagram

Instagram bundle for Contao Open Source CMS

167.5k](/packages/codefog-contao-instagram)[aura/includer

Include multiple files from specified directories, in order, with variables extracted into a limited include scope.

133.2k](/packages/aura-includer)

PHPackages © 2026

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