PHP code example of littlemo / tool

1. Go to this page and download the library: Download littlemo/tool 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 / tool example snippets


use littlemo\tool\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\tool\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\tool\Download;

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

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

json
{
    "hp": "^7.4",
        "littlemo/tool": "*"
    }
}