PHPackages                             littlemo/utils - 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. littlemo/utils

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

littlemo/utils
==============

the littlemo common utils

v1.4.3(10mo ago)23874Apache-2.0PHPPHP ^7.0||^8.0

Since Nov 11Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/littlemolh/composer-utils)[ Packagist](https://packagist.org/packages/littlemo/utils)[ Docs](https://ggui.cn/)[ RSS](/packages/littlemo-utils/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (2)Versions (43)Used By (4)

Littlemo utils
==============

[](#littlemo-utils)

[![Total Downloads](https://camo.githubusercontent.com/8f1177bb14fec0f8ca8fb3a03676de913abe7bf22ad8c5024a1f6f7f474c7836/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f7574696c732f646f776e6c6f616473)](https://packagist.org/packages/littlemo/utils)[![Latest Stable Version](https://camo.githubusercontent.com/9feea3dfda6b0ad1e0ca512daff24202cbecfed1e4d1204ced73dfc072a4e1ca/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f7574696c732f762f737461626c65)](https://packagist.org/packages/littlemo/utils)[![Latest Unstable Version](https://camo.githubusercontent.com/e5bb27afd8ccbf92e38013e50d5334a5b908058917fa1c085cdf57c14b6023fb/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f7574696c732f762f756e737461626c65)](https://packagist.org/packages/littlemo/utils)[![PHP Version](https://camo.githubusercontent.com/21223b9ffedc1feec4026ec59947bafeec1e45b69a0e2fd1383975636e8d09a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e302d3838393242462e737667)](http://www.php.net/)[![License](https://camo.githubusercontent.com/cb2d6be23335635ea8a9f4f8d6eeaa3b48a4aec9e32ff476d79caf91d6b99f4f/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f7574696c732f6c6963656e7365)](https://packagist.org/packages/littlemo/utils)

介绍
--

[](#介绍)

php常用工具库

安装
--

[](#安装)

composer.json

```
{
    "require": {
        "littlemo/utils": "1.4.*"
    }
}
```

```
composer require littlemo/utils:"1.4.*"
```

使用
--

[](#使用)

### 统计单位时间内同一个IP请求次数

[](#统计单位时间内同一个ip请求次数)

> 需要安装`redis`扩展,并启动 `redis` 服务

#### 示例代码

[](#示例代码)

```
use littlemo\utils\RequestRate;
$config=[
    'prefix'=>'ip',//缓存前缀
    'time'=>'60',//单位时间（s）
    'maxCount'=>'30',//单位时间最大请求次数
    'cache'=>[
        'type' => 'redis',//缓存类型，目前仅支持redis
        'host' => '127.0.0.1',//缓存服务连接地址
        'port' => '6379',//缓存服务端口
        'select' => 0,//redis库号，一般取值范围（0-15）
    ]
]

//实例化对象
$requestRate = new RequestRate($config);

//获取错误信息
$error = $requestRate->$getMessage();

//初始化缓存服务,实例化对象时回自动初始化缓存服务
$requestRate->setCacheObj();

//验证器
$result = $requestRate->check();
if($result === false){
    echo $requestRate->$getMessage();
}else{
    echo '未达到请求次数上限';
}
```

#### 自动更新Git

[](#自动更新git)

> 仅支持gitee

##### 示例代码

[](#示例代码-1)

```
use littlemo\utils\Git;

$token = 'XXXXXXX';

//实例化对象
$Git = new Git($token);

//验证器
$error = $Git->check($token);

/**
* 拉取代码
* @param string $path   执行脚本相对路径；默认：'..'
* @param string $exec   执行脚本；默认：'git pull origin master'
*/
$Git->pull($path, $exec);
```

- 拉取代码的日志会直接在页面输出

#### 下载文件

[](#下载文件)

##### 示例代码

[](#示例代码-2)

```
use littlemo\utils\Download;

/**
* 下载文件
* @param string $file      文件路径（文件所在磁盘的绝对路径）
* @param string $filename  带后缀的(自定义)文件名称
*/

Download::file($file, $filename);
```

#### Tools

[](#tools)

```
use littlemo\utils\Tools;
```

#### 生成随字符串

[](#生成随字符串)

##### 示例代码

[](#示例代码-3)

```
$string = Tools::createNonceStr($length , $enum ,  $dict);
```

参数说明

参数类型默认说明lengthint32制作随机字符串长度enumArray\['0','a','A'\]字符串类型选择（0=0-9，a=a-z,A=A-Z）dictstring初始字符库（自定义字符库）#### 制作签名

[](#制作签名)

##### 示例代码

[](#示例代码-4)

```
$string = Tools::createSign($params, $params_disorder, $type);
```

参数说明

参数类型必填默认说明paramsArrayY需要按照字段名的ASCII 码从小到大排序（字典序）的参数params\_disorderArrayN\[\]无需排序操作的参数typestringNmd5加密方式(可选：md5,MD5,sha1,SHA1)type可选参数说明

参数说明md5以 32 字符的十六进制数形式返回散列值MD5以 16 字符长度的原始二进制格式返回sha140 字符长度的十六进制数SHA1以 20 字符长度的原始二进制格式返回#### Banner

[](#banner)

```
use littlemo\utils\Banner;
```

#### 合成图片

[](#合成图片)

##### 示例代码

[](#示例代码-5)

```
Banner::create(720, 780);//创建图像
Banner::setBgColor();//设置图像背景颜色
Banner::addImage('11.jpg',' 0, 0',' 0, 0');//添加图片

$color = Banner::setColor(0, 0, 0);//获取颜色int值
Banner::addText('20211225195933079158', 20, '200,740',  $color);//添加文字

Banner::output();//输出图像
Banner::save(date("YmdHis") . '.png');//保存图像
print_r(Banner::getMessage());//输出错误信息
```

### 参与贡献

[](#参与贡献)

1. littlemo

### 特技

[](#特技)

- 简洁易用

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance54

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 57.6% 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 ~33 days

Recently: every ~230 days

Total

42

Last Release

309d ago

PHP version history (2 changes)v1.0.1PHP ^7.0

v1.0.12PHP ^7.0||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16798708?v=4)[25362583](/maintainers/25362583)[@25362583](https://github.com/25362583)

![](https://avatars.githubusercontent.com/u/43428262?v=4)[xiaowei95](/maintainers/xiaowei95)[@xiaowei95](https://github.com/xiaowei95)

---

Top Contributors

[![littlemolh](https://avatars.githubusercontent.com/u/26665792?v=4)](https://github.com/littlemolh "littlemolh (34 commits)")[![25362583](https://avatars.githubusercontent.com/u/16798708?v=4)](https://github.com/25362583 "25362583 (25 commits)")

---

Tags

toolutilsqqlittlemo

### Embed Badge

![Health badge](/badges/littlemo-utils/health.svg)

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

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.2M192](/packages/danielstjules-stringy)[phing/phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

1.2k22.2M901](/packages/phing-phing)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

52823.6M1.0k](/packages/bamarni-composer-bin-plugin)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4885.6M18](/packages/voku-arrayy)[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)[voku/stringy

A string manipulation library with multibyte support

1793.9M24](/packages/voku-stringy)

PHPackages © 2026

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