phpyii/php-storage
Composer 安装命令:
composer require phpyii/php-storage
包简介
上传文件
README 文档
README
文件上传
简介
php-storage PHP多存储驱动的文件管理类,支持多种云存储平台。
支持平台
- 本地服务器
- 腾讯云 COS
- 阿里云 OSS
- 七牛云存储
- 又拍云存储
环境支持
php版本 >= PHP 7.1
安装
composer require phpyii/php-storage
//开发版本
composer require phpyii/php-storage:dev-master
使用方法
$file = new FileObject(); //本地存储 $file->setDriver([ 'type' => 'local', 'config' => [ 'domain' => 'http://www.baidu.com', 'save_path' => 'E:/', ], ]); //腾讯cos //$file->setDriver([ // 'type' => 'cos', // 'config' => [ // 'secret_id' => '', // 'secret_key' => '', // 'app_id' => '', // 'bucket' => '', // 'region' => 'ap-beijing', // 'domain' => '', //留空自动设置 // 'use_ssl' => false, // ], //]); //阿里oss //$file->setDriver([ // 'type' => 'oss', // 'config' => [ // 'secret_id' => '', // 'secret_key' => '', // 'bucket' => '', // 'region' => 'oss-cn-hangzhou', // 'domain' => '', //留空自动设置 // 'use_ssl' => false, // ], //]); //七牛 //$file->setDriver([ // 'type' => 'qiniu', // 'config' => [ // 'access_key' => '', // 'secret_key' => '', // 'bucket' => '', // 'domain' => 'http://www.baidu.com', // 'api_host' => 'up.qiniup.com', // 'use_ssl' => false, // ], //]); //又拍云 //$fileObject->setDriver([ // 'type' => 'upyun', // 'config' => [ // 'operator' => '', // 'password' => '', // 'bucket' => '', // 'domain' => '', // 'api_host' => 'v0.api.upyun.com', // 'use_ssl' => false, // ], //]); //其他继承了DriverAbstract类的所有自定义类都可以 //$customClass = new CustomClass(); //$file->setDriver($customClass); //上传 //$file->fileTmpPath = 'E:/a.jpg'; //$file->oldName = 'a.jpg'; //原文件名 可留空 ////$file->filePath = ''; //带后缀的新文件名称 留空自动生成 ////$fileObject->fileBase64 = ''; //图片base64字符串 data:image/png;base64,后边的字符串 ////$file->ext = 'jpg'; //文件后缀 留空自动获取 ////$file->allowExts = ['png','jpg', 'txt']; //允许的后缀 ////$file->mime = 'image/jpeg'; //留空通过后缀自动获取 //$file->saveDir = 'dev/test'; //保存目录 //$file->dateDir = true; //是否自动追加日期目录 //$file->isCover = true; //是否覆盖 ////$file->maxSize = 1048576; //限制文件大小 //$bool = $file->save(); //if($bool){ // //文件保存路径 // //$file->filePath; // //文件访问路径 // //$file->fileUrl; //} // else{ // var_dump($file->getMsg()); // } //删除 //$bool = $file->del('/dev/test/2020/0910/08e87202009101612179540.jpg'); //或者 //$file->filePath = '/dev/test/2020/0910/08e87202009101612179540.jpg'; //$bool = $file->del(); //文件是否存在 $bool = $file->has('/dev/test/2020/0910/0e80b202009101613326313.jpg'); //或者 //$file->filePath = '/dev/test/2020/0910/08e87202009101612179540.jpg'; //$bool = $file->has(); //操作结果 var_dump($bool); //请求结果 var_dump($file->getResult());
phpyii/php-storage 适用场景与选型建议
phpyii/php-storage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「file」 「storage」 「upload」 「oss」 「upyun」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpyii/php-storage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpyii/php-storage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpyii/php-storage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Laravel Media Popup to upload/view the files
PMVC Plugin for File information
Mapper for accessing resources in KWCMS
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-09