PHP code example of littlemo / utils

1. Go to this page and download the library: Download littlemo/utils library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

littlemo / utils example snippets


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 '未达到请求次数上限';
}


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);


use littlemo\utils\Download;

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

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


use littlemo\utils\Tools;



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



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


use littlemo\utils\Banner;


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());//输出错误信息