PHPackages                             luguohuakai/srun - 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. luguohuakai/srun

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

luguohuakai/srun
================

srun soft tools

v2.0.1(2y ago)2155MITPHPPHP &gt;=7.4

Since Apr 15Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/luguohuakai/srun)[ Packagist](https://packagist.org/packages/luguohuakai/srun)[ Docs](https://github.com/luguohuakai/srun)[ RSS](/packages/luguohuakai-srun/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (21)Used By (0)

SRUN
====

[](#srun)

> PHP &gt;= 7.4
>
> 引入: composer require luguohuakai/srun:~1.0.0
>
> SRUN SDK(北向接口/单点登录) 和常用工具类封装

- 部分接口未实现的,或者需要扩展的,可以继承相应模块自行实现,也可以GitHub提交PR(欢迎PR)
- 未实现接口或这里调用方式不能满足需求的也可自行根据北向接口文档进行调用
- 日志: srun4k环境下默认位于: `/srun3/log/srun/`; 非srun4k环境: `/var/log/srun/`
- 如果要使用SDK请到srun4k 8080中配置北向接口权限
- 支持的接口 随北向接口更新

### 当前支持的北向接口有(V1)

[](#当前支持的北向接口有v1)

```
new User(); // 用户相关
new Alipay(); // 支付相关
new Auth(); // 鉴权相关
new Financial(); // 财务相关
new Group(); // 用户组相关
new Message(); // 消息相关
new Package(); // 套餐相关
new Product(); // 产品相关
new Setting(); // 设置相关
new Srun(); // 北向接口基类
new Strategy(); // 策略相关
```

### 支持北向接口V2

[](#支持北向接口v2)

```
new SrunV2(); // 基础服务
new UserV2(); // 用户相关
new VisitorV2(); // 访客相关
new GroupV2(); // 用户组相关
new BillingStrategyV2(); // 计费策略相关
new FinancialV2(); // 财务相关
new OnlineStrategyV2(); // 用户上网策略相关
new DeviceV2(); // 上网设备相关
new OnlineV2(); // 在线相关
new OnlineDetailV2(); // 上网明细相关
new MessageV2(); // 通知公告相关
new ManagerV2(); // 管理员相关
new LogV2(); // 日志相关
new StatisticsV2(); // 统计类接口
```

### 使用方法

[](#使用方法)

```
use func\src\Func;
use srun\src\Srun;
use srun\src\User;

// 基本用法 (使用默认地址: https://127.0.0.1:8001/)
$user = new User;
$user->view('srun');

// 手动配置接口地址
$user = new User('https://127.0.0.1:8001/')
$user->view('srun');

// 使用配置文件 配置文件参考 `vendor/luguohuakai/srun/config/srun.ini`
$ini = parse_ini_file('./srun.ini', true);
$user = new User(...$ini['north'])
$user->view('srun');

// 也可以先在自己项目中先初始化再调用
function initUser(): User
{
    $ini = parse_ini_file('./srun.ini');
    return new User($ini['srun_north_api_url']);
}
initUser()->view('srun');

// 手动配置缓存redis 老版本 < 1.0.8
$user = new User;
$user->setRdsConfig(['port' => 6380, 'host' => '127.0.0.1', 'pass' => 'xxx']);
$user->view('srun');

// 根据文档自行调用北向接口方式
$srun = new Srun;
$srun->req('path/to/api/addr', ['param1' => 'xxx', 'param2' => 'xxx'], 'post');
```

### 缓存类使用方法

[](#缓存类使用方法)

> 新版缓存逻辑: srun4k环境: 自动设置为redis缓存(16382); 非srun4k环境: 自动设置为文件缓存

```
/**
 * 目前支持 文件缓存 redis缓存
 * @param int $type 可选 0:自动设置 1:文件缓存Cache::CACHE_FILE, 2:redis缓存Cache::CACHE_REDIS
 * @param string $cache_file 可选 自定义文件缓存位置
 * @param array $rds_config 可选 自定义redis缓存配置 如: ['index' => 0,'port' => 6379,'host' => '127.0.0.1','pass' => null]
 */
use srun\src\Cache;

$cache = new Cache;
$cache->set($key, $value);
$cache->get($key);
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance47

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

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

Recently: every ~115 days

Total

20

Last Release

191d ago

Major Versions

v1.0.11 → v2.0.02023-09-08

PHP version history (2 changes)1.0.0PHP &gt;=7.0

v2.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f4e6db0dd083b1cc18593e5eb511d7afbd6ac00c0c0caab1ce9f3e82f8e58b8?d=identicon)[luguohuakai](/maintainers/luguohuakai)

---

Top Contributors

[![luguohuakai](https://avatars.githubusercontent.com/u/16839001?v=4)](https://github.com/luguohuakai "luguohuakai (40 commits)")

---

Tags

toolssrunsrunsoftsrunsoft tools

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/luguohuakai-srun/health.svg)

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

###  Alternatives

[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

3014.5M22](/packages/vaimo-composer-patches)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

333972.2k49](/packages/dereuromark-cakephp-tools)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147253.5k7](/packages/longman-ip-tools)[codeigniter4/devkit

Development toolkit for CodeIgniter libraries and projects

68195.7k114](/packages/codeigniter4-devkit)[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7135.7k29](/packages/ramsey-devtools)[glpi-project/tools

Various tools for GLPI and its plugins

13743.2k4](/packages/glpi-project-tools)

PHPackages © 2026

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