camilord / utilus
Camilo3rd的PHP工具库
1.0.39
2024-07-03 00:35 UTC
Requires
- php: >=7.4
- ext-ctype: *
- ext-curl: *
- ext-json: *
- ext-openssl: *
Requires (Dev)
- doctrine/dbal: 2.5.4
- phpunit/phpunit: ^5
This package is auto-updated.
Last update: 2024-09-17 12:05:41 UTC
README
Camilo3rd的PHP工具库
安装库
{
"require": {
"camilord/utilus": "^1.0"
}
}
或
composer require camilord/utilus
使用
这个库是我从各种项目中收集的。它是一个小型库,每次我创建一个项目,我都不需要重新创建这些类和函数,我只需要添加这个包并开始工作。以下是一些示例
生成UUID
// I need UUID
echo UUID::v4();
输出
b9ef0e9e-3249-31a1-a529-640a129890ac
上传文件
// I need to process upload file
$tmp_dir = '/tmp/junkies/';
$uploader = new FileUpload($_FILES);
$uploader->setTemporaryUploadDir($tmp_dir, true);
$fileObj = $uploader->processUpload('document_name');
echo $fileObj->getFilePath();
输出
/tmp/junkies/tmp_073240_03927845092742.jpg
获取域名SSL过期剩余天数
// I need to know the number of days left for my domain SSL
$sslUtil = new SSLUtil();
$url = 'https://www.abcs.co.nz';
$days = $sslUtil->getSslDaysLeft($url);
if ($days === false) {
echo "Error! Cannot fetch SSL information.";
} else {
echo $days.' days left';
}
输出
剩余370天