PHPackages                             caichuanhai/storage - 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. caichuanhai/storage

ActiveLibrary

caichuanhai/storage
===================

caichuanhai storage lib

16PHP

Since May 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/caichuanhai/Storage)[ Packagist](https://packagist.org/packages/caichuanhai/storage)[ RSS](/packages/caichuanhai-storage/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

storage
=======

[](#storage)

关于
--

[](#关于)

第三方存储库，将阿里云，七牛云，腾讯云的对象存储功能进一步封装成统一接口，可随意切换，不用修改业务代码，暂支持上传文件，删除文件，批量删除，移动文件，复制文件。后期将加入更多文件管理和bucket管理功能。

安装
--

[](#安装)

1. composer安装

```
composer require caichuanhai/router
```

2. 普通安装 下载源码压缩包： 解压到您项目的目录中，然后在您的项目中引入 autoloader：

```
require 'path_to_sdk/autoload.php'
```

初始化
---

[](#初始化)

```
use \Caichuanhai\Storage;

// $storage = new Storage('qiniu', array('ak' => 'Access_Key', 'sk' => 'Secret_Key'));
// $storage = new Storage('aliyun', array('ak' => 'yourAccessKeyId', 'sk' => 'yourAccessKeySecret', 'ep' => 'endpoint'));
// $storage = new Storage('tencent', array('si' => 'COS_SECRETID', 'sk' => 'COS_SECRETKEY', 'region' => 'COS_REGION'));

$storage->setBucket('yourBucket');
```

目前在初始始化时可指定qiniu，aliyun，tencent中任意一个，根据所选产品不同，后面所传数组参数也不相同，具体参数数值可在对应产品后台获取。

`setBucket`方法为设置要操作的bucket，在操作文件中途也可再次调用该方法以切换不同bucket。

上传文件
----

[](#上传文件)

```
$storage->uploadFile(pathToFile, newName)
```

参数名必填默认值说明pathToFile是无要上传文件全路径，包括文件名newName否无新文件名，包含后缀，若为空，则用旧文件名返回值： \[bool, msg\] 上传成功，则msg为上传后的文件名，若失败，msg为错误消息

删除文件
----

[](#删除文件)

```
$storage->deleteFile(fileName, Bucket)
```

参数名必填默认值说明fileName是无要删除的文件名Bucket否无bucket，若为空，则用`setBucket`方法所设置的bucket返回值： \[bool, msg\] 删除状态，若失败，msg为错误消息

批量删除文件
------

[](#批量删除文件)

```
$storage->batchDeleteFile(fileNames, Bucket)
```

参数名必填默认值说明fileNames是无要删除的文件名数组，以文件名组成的一维数组Bucket否无bucket，若为空，则用`setBucket`方法所设置的bucket返回值： \[bool, msg\] 删除状态，若失败，msg为错误消息

移动复制文件
------

[](#移动复制文件)

```
$storage->moveFile(oldObject, newObject, retain)
```

参数名必填默认值说明oldObject是无源文件，以bucket和文件名组成，以:分隔，\[oldBucket\]:oldName 若oldBucket为空，则用`setBucket`方法所设置的bucketnewObject是无移动或复制后的文件，以bucket和文件名组成，以:分隔，\[newBucket\]:\[newName\] 若newBucket为空，则用`setBucket`方法所设置的bucket，若newName为空，则用旧文件名retain否false是否保留旧文件，默认false不保留，等同于移动，若保留，则为复制返回值： \[bool, msg\] 移动状态，若失败，msg为错误消息

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d779dc4497d871757a46a28830e523d6e1709d5bf21bface555522d5f9eba579?d=identicon)[caichuanhai](/maintainers/caichuanhai)

---

Top Contributors

[![caichuanhai](https://avatars.githubusercontent.com/u/5926373?v=4)](https://github.com/caichuanhai "caichuanhai (13 commits)")

### Embed Badge

![Health badge](/badges/caichuanhai-storage/health.svg)

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

PHPackages © 2026

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