PHPackages                             mryup/filestore - 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. mryup/filestore

ActiveLibrary

mryup/filestore
===============

文件上傳保存在 cos/oss

v1.0.2(2y ago)055↓100%PHPPHP &gt;=7.2

Since Mar 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/MrYup/filestore)[ Packagist](https://packagist.org/packages/mryup/filestore)[ RSS](/packages/mryup-filestore/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

更新
--

[](#更新)

1. 移除本地存储, 要存储在本地,用`hf`的方法就好了。
2. 增加[cos](https://cloud.tencent.com/document/product/436/34282)存储
3. 增加`put`方法
4. 改善之前的代码

[扩展源码](https://gitee.com/lyxxxh/filestore/tree/master/src/Service)

安装
--

[](#安装)

1. `composer require mryup/filestore`​
2. `php bin/hyperf.php vendor:publish mryup/filestore` // 发布配置 ​
3. 配置`config/autoload/filestore.php` //配置oss

```
'oss' => [
		'appid' => '',
		'appsec' => '',
		'bucket' => '',
		'endpoint' => '',
		'socket_timeout' => '5184000', // 设置Socket层传输数据的超时时间
		'connection_timeout' => '10', //建立链接的超时时间
		'save_path' => 'tem/storage/',  //存储目录
]

```

控制器使用
-----

[](#控制器使用)

```
use Xxh\FileStore\Service\FileStoreAbstract;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
​

/**
* 文件管理
* @Inject
* @var FileStoreAbstract
*/
private $file;
​
//接收文件上传
public function filestore(RequestInterface $request, ResponseInterface $response)
{
	$path = $this->file->store(
	 $request->file('img')
	);
	return $this->file->url($path);    
	//http://r-card.oss-cn-beijing.aliyuncs.com/tem/storage/4b7dd3231926a340ab84d53316f17e03.png
}
​

public function put()
{
	$path = $this->file->put('1.txt','Hello World');
	return $this->file->url($path);
		  //http://r-card.oss-cn-beijing.aliyuncs.com/tem/storage/1.txt

}

```

使用cos
-----

[](#使用cos)

1. 新增`config/autoload/dependencies.php`配置

```
 Xxh\FileStore\Service\FileStoreAbstract::class => Xxh\FileStore\Service\CosFileStoreService::class

```

2. 配置`config/autoload/filestore.php`的`cos`的信息

扩展方法 或者 重写 (以oss为例)
-------------------

[](#扩展方法-或者-重写-以oss为例)

1. 随便创建一个文件 例:`app/Services/OssFileStoreService.php`
2. 修改`config/autoload/dependencies.php`为

```
Xxh\FileStore\Service\FileStoreAbstract::class => App\Services\OssFileStoreService::class

```

3. `OssFileStoreService.php内容`

```
class OssFileStoreService extends Xxh\FileStore\Service\OssFileStoreService
{
//重写oss put方法
public function put($filename,$str)
{
	.....
}

//新增oss delObject方法
public function delObject($filename)
{
	$this->getClient()->deleteObjects($this->config['bucket'],$filename);
}

}

```

扩展提供的方法
-------

[](#扩展提供的方法)

见[FileStoreAbstract.php](https://gitee.com/lyxxxh/filestore/blob/master/src/Service/FileStoreAbstract.php)

超过2m无法上传
--------

[](#超过2m无法上传)

默认只能上传2M的文件， 请看[swoole文档 (package\_max\_length)](https://wiki.swoole.com/wiki/page/301.htmlhttps://wiki.swoole.com/wiki/page/301.html)

可在config/server.php的

```
settings =>[
    'package_max_length' => 5 * 1024 * 1024 , //5M
    .....
]

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

798d ago

### Community

Maintainers

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

---

Top Contributors

[![Heatstorm](https://avatars.githubusercontent.com/u/101440826?v=4)](https://github.com/Heatstorm "Heatstorm (3 commits)")

---

Tags

phphyperf

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mryup-filestore/health.svg)

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

PHPackages © 2026

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