定制 hardai/thinkphp-filesystem 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hardai/thinkphp-filesystem

最新稳定版本:v0.0.1

Composer 安装命令:

composer require hardai/thinkphp-filesystem

包简介

thinkphp8.0 filesystem,include Local Aliyun Qiniu Qcloud

README 文档

README

thinkphp8.0 filesystem,include Local Aliyun Qiniu Qcloud

#安装 composer require hardai/thinkphp-filesystem

使用实例:

1# .ENV 文件设置默认驱动aliyun

[FILESYSTEM] DRIVER=aliyun

2# filesystem.php 文件配置修改

return [
    // 默认磁盘
    'default' => 'aliyun',
    // 磁盘列表
    'disks'   => [
        'local'  => [
            'type' => 'local',
            'root' => app()->getRuntimePath() . 'storage',
        ],
        'public' => [
            // 磁盘类型
            'type'       => 'local',
            // 磁盘路径
            'root'       => app()->getRootPath() . 'public/storage',
            // 磁盘路径对应的外部URL路径
            'url'        => '/storage',
            // 可见性
            'visibility' => 'public',
        ],
        // 更多的磁盘配置信息
        'aliyun' => [
            'type'         => 'aliyun',
            'accessId'     => '',
            'accessSecret' => '',
            'bucket'       => '',
            'endpoint'     => 'oss-cn-beijing.aliyuncs.com',
            'url'          => '',//不要斜杠结尾,此处为URL地址域名。
        ]
    ],
];

3#Thinkphp8中使用示例

$file = request()->file();
if (empty($file) || !isset($file['img']) || empty($file['img'])) {
    return json_error('请上传图片');
}
try {
    validate(['img' => 'fileSize:10485670|fileExt:jpg,gif,jpeg,png|fileMime:image/jpeg,image/gif,image/png'])
        ->check($file);
    $path = \think\facade\Filesystem::putFile('images', $file['img']);
    $path = \think\facade\Filesystem::geturl($path);
    return  $path;
} catch (\think\exception\ValidateException $e) {
    return $e->getMessage();
}

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-25