PHPackages                             smileyi/ytil - 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. [Image &amp; Media](/categories/media)
4. /
5. smileyi/ytil

ActiveLibrary[Image &amp; Media](/categories/media)

smileyi/ytil
============

v0.1.5(6y ago)36MITPHPPHP &gt;=7.0

Since Apr 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/smile-yi/Ytil)[ Packagist](https://packagist.org/packages/smileyi/ytil)[ RSS](/packages/smileyi-ytil/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (6)Used By (0)

Ytil
====

[](#ytil)

### PHP常用工具包(网络调用、参数校验)

[](#php常用工具包网络调用参数校验)

#### 安装方法

[](#安装方法)

```
composer require smileyi/ytil

```

#### 基础配置

[](#基础配置)

```
use SmileYi\Ytil\Config;

Config::set([
    'log' => [
        // 日志存储路径
        'dir' => dirname(__FILE__) . '/../extra/log/',
    ],
    'common' => [
        //加密盐值
        'salt' => '4ckNt8GrgvqXYg1u',
    ],
    'base64' => [
        // 编码表
        // 'map' => 'OBrsYZabgQRSTUtu3JnoPDChijklWApqKLM6Evw7Ncde45mxGHIfXyz012FV89+/',
        'map' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
    ],
    'upload' => [
        // 上传目录
        'dir' => dirname(__FILE__) . '/../extra/upload/',
        // 允许的文件类型
        'exts' => ['jpg', 'png', 'jpeg'], // 不限制: ['*']
        // 文件大小限制
        'size' => 1024 * 1024 * 2,
    ],
])

```

#### 工具列表

[](#工具列表)

- 网络调用
- 参数验证
- Base64编码
- 加密解密
- 文件上传
- 日志写入

#### 具体用法

[](#具体用法)

##### Http调用

[](#http调用)

```
use SmileYi\Ytil\Http;
use SmileYi\Ytil\Exception;

$url = 'http://192.144.150.100/api.php?method=get&task_id=1001';
$header = [
    'Content-type' => 'application/json',
    'User-agent' => 'utils/http'
];
$body = [
    'param1' => 'value1'
];

//代理配置
//$proxy = 'http://xxx.xxx.xxx.xxx:8080'
$proxy = null;

//证书配置
// $cert = [
//     'ssl_cert' => 'path',
//     'ssl_key' => 'path',
//     'ca_info' => 'path'
// ];
$cert = null;

try {
    //GET调用
    $result = Http::get($url, $header, $proxy, $cert);
    var_dump($result);

    //POST调用
    $result = Http::post($url, $body, $header, $proxy, $cert);
    var_dump($result);

    //并行调用
    $multi = [];
    $multi['name1'] = [
        'method' => Http::METHOD_GET,
        'url' => $url,
        'header' => $header
    ];
    $multi['name2'] = [
        'method' => Http::METHOD_POST,
        'url' => $url,
        'header' => $header,
        'body' => $body
    ];

    $result = Http::multi($multi);
    var_dump($result);
}catch(Exception $e){
    echo "Errno:" . $e->getCode() . " Error:" . $e->getMessage()."\n";
}

```

##### 日志写入

[](#日志写入)

```
use SmileYi\Ytil\Log;

Log::getInstance()->put('user', ['nickname' => 'smileyi', 'sex' => 1]);

```

##### 常用工具

[](#常用工具)

```
use SmileYi\Ytil\Common;

# 加密解密
$t = 'hahaha';
$dt = Common::encrypt($t);
$et = Common::decrypt($dt);
echo "secret text:" . $dt . "\n";
echo "text:" . $et . "\n\n";

# 耗时计算
Common::exeTime('_start');
sleep(0.1);
Common::exeTime('_end');
echo "Exe time is:" . Common::exeTime('_start', '_end') . "s\n\n";

# 获取随机长度字符串
echo "random string is:" . Common::randStr(10) . "\n\n";

# 获取客户端IP
echo "client ip is:" . Common::getClientIp() . "\n\n";

```

##### Base64编码解码

[](#base64编码解码)

```
use SmileYi\Ytil\Base64;

$text = 'smileyi';

# 编码
$dt = Base64::encode($text);
# 解码
$et = Base64::decode($dt);

echo "text base64 encode is:" . $dt . "\n";
echo "text is:" . $et . "\n\n";

```

##### 参数校验

[](#参数校验)

```
use SmileYi\Ytil\Format;

# 邮箱
$bool = Format::isEmail('haha@gmail.com');

# 手机号
$bool = Format::isMobile('188xxxxxxxx');

# url
$bool = Format::isUrl('http://www.github.com/');

# 身份证号
$bool = Format::isIdCard('1775443288743221234');

# 整数
$bool = Format::isInteger(1001);

# json
$bool = Format::isJson('{"name":"smileyi"}');

# 用户名(6-16位数字+字母+_)
$bool = Format::isUsername('smileyi');

# 密码(6-20位数字+字母+_)
$bool = Format::isPassword('haha1234');

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

5

Last Release

2475d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40b2f75d8db3a033b0ce299f443d74ca0c3bb08f02c88d58802c549af61957b7?d=identicon)[smileyi](/maintainers/smileyi)

---

Top Contributors

[![smile-yi](https://avatars.githubusercontent.com/u/11816185?v=4)](https://github.com/smile-yi "smile-yi (12 commits)")

---

Tags

httpimagesecretuploadutils

### Embed Badge

![Health badge](/badges/smileyi-ytil/health.svg)

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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