PHPackages                             medz/oss-stream-wrapper - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. medz/oss-stream-wrapper

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

medz/oss-stream-wrapper
=======================

A Aliyun OSS streamWrapper class and Aliyun OSS SDK.

v1.0.5(8y ago)71464[1 issues](https://github.com/medz/oss-stream-wrapper/issues)1MITPHPPHP &gt;=5.4

Since Sep 1Pushed 6y ago2 watchersCompare

[ Source](https://github.com/medz/oss-stream-wrapper)[ Packagist](https://packagist.org/packages/medz/oss-stream-wrapper)[ Docs](http://medz.cn)[ RSS](/packages/medz-oss-stream-wrapper/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (1)

Aliyun OSS support streamWrapper. (&amp;Aliyun OSS SDK for PHP.) 支持OSS自定义流协议操作。
===============================================================================

[](#aliyun-oss-support-streamwrapper-aliyun-oss-sdk-for-php-支持oss自定义流协议操作)

[![Build Status](https://camo.githubusercontent.com/f0a236cf148cfa0cf93b8113c3ae5f9027e139885fb644519f1a1f58d97d3c4f/68747470733a2f2f7472617669732d63692e6f72672f6d65647a2f6f73732d73747265616d2d777261707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/medz/oss-stream-wrapper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9390715c82bf4fe681caeba5ecb8b4c0357d97e4d6ad9a9b48de0713b0e7b26b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d65647a2f6f73732d73747265616d2d777261707065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/medz/oss-stream-wrapper/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/ff9472fe0cafa0e19313d09eb8ca0c8362702628987ce749ba05e2ee7d04dd0a/68747470733a2f2f706f7365722e707567782e6f72672f6d65647a2f6f73732d73747265616d2d777261707065722f76657273696f6e)](https://packagist.org/packages/medz/oss-stream-wrapper)[![Total Downloads](https://camo.githubusercontent.com/888239cc024980c4e26be60f43b94c00667ed29eea96224433edad487fc5c4f1/68747470733a2f2f706f7365722e707567782e6f72672f6d65647a2f6f73732d73747265616d2d777261707065722f646f776e6c6f616473)](https://packagist.org/packages/medz/oss-stream-wrapper)[![Latest Unstable Version](https://camo.githubusercontent.com/ea4e9fc5c6bf8ed44c34ad316d264a74ce87de9e319c11583226f57732082131/68747470733a2f2f706f7365722e707567782e6f72672f6d65647a2f6f73732d73747265616d2d777261707065722f762f756e737461626c65)](//packagist.org/packages/medz/oss-stream-wrapper)[![License](https://camo.githubusercontent.com/b69ef991355e75c541cef15e46b09b992804b62cd70bb7696e317aea3af93599/68747470733a2f2f706f7365722e707567782e6f72672f6d65647a2f6f73732d73747265616d2d777261707065722f6c6963656e7365)](https://packagist.org/packages/medz/oss-stream-wrapper)

概述
--

[](#概述)

看名字就知道，这个包住要实现了oss的流协议封装，因为是基于官方sdk，也包含了官方sdk的全部功能，应该说，这个包，是在官方的sdk基础上增加流协议功能。

sdk文档
-----

[](#sdk文档)

[Aliyun OSS SDK](https://github.com/medz/aliyun-oss-php-sdk/blob/master/README.md)

Composer
--------

[](#composer)

```
composer require medz/oss-stream-wrapper
```

### 别名包

[](#别名包)

- ⚠️*如果*觉得这个包的名字不是那么容易记住，请看另一个包[medz/aliyun-oss](https://packagist.org/packages/medz/aliyun-oss)这个包作为本包的别名，为了更方便的记忆，当然，类名称有所变化。
- composer:

```
composer require medz/aliyun-oss
```

Demo
----

[](#demo)

```
use Medz\Component\StreamWrapper\AliyunOSS\AliyunOSS;

#  如果使用的是medz/aliyun-oss这个包
# use Medz\Component\AliyunOSS\AliyunOSS;

$accessKeyId = ""; ;
$accessKeySecret = "";
$endpoint = "";
$bucket = "";
$oss = new AliyunOSS($$accessKeyId, $$accessKeySecret, $$endpoint);
$oss->setBucket($bucket);

// 重要步骤，注册流协议（可以注册多个）
$oss->registerStreamWrapper('oss'); // 默认流协议注册的是 oss:// 这个是可以自定义的，就在这里，定义你希望的流协议前缀。
```

到了这一步，已经成功的注册了流协议，我们来看看怎么使用吧，先来个最简单的写入文件：

```
file_put_contents('oss://demo/test.txt', 'This is a test content.');
```

很简单吧？如此以来就可以使用原生的文件操作函数或者类来操作oss上的object了～

案例：如何在symfony/finder中使用自定义流协议。
------------------------------

[](#案例如何在symfonyfinder中使用自定义流协议)

首先我说一点，我们都知道，finder组件是可以支持s3等云存储的，没错，finder本身不支持云存储，而是通过自定义流协议完成的，这个在组件文档中有例子，我们来看看在oss中怎么使用它。

```
// 上面我们已经注册了流协议，所以这里直接写重点代码。
use Symfony\Component\Finder\Finder;

$finder = new Finder();

$path = 'oss://demo'; //拟定一个已经存在的目录，如果不存在也没关系，流协议中已经支持了目录存在与否的判断，是本地文件一样，没有任何区别。
$finder->files()->in($path);

foreach ($finder as $file) {
  var_dump($file); // Symfony\Component\Finder\SplFileInfo
}
```

这样，我们就遍历出了在demo目录下存在的文件了。

更多
--

[](#更多)

如果你觉得，这个是自定义协议流的很好案例，但是你却不知道具体需要实现什么方法，没关系，你只需要依赖一个只包含一个接口类的组件，继承它，实现里面的方法，就可以完成你的自定义流协议。

组件：[medz/stream-wrapper-interface](https://packagist.org/packages/medz/stream-wrapper-interface)

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~127 days

Recently: every ~159 days

Total

6

Last Release

2952d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5564821?v=4)[Seven Du](/maintainers/medz)[@medz](https://github.com/medz)

---

Top Contributors

[![augustyip](https://avatars.githubusercontent.com/u/1473436?v=4)](https://github.com/augustyip "augustyip (2 commits)")[![medz](https://avatars.githubusercontent.com/u/5564821?v=4)](https://github.com/medz "medz (1 commits)")

---

Tags

phpwrapperstreamwrapperossmedz

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/medz-oss-stream-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/medz-oss-stream-wrapper/health.svg)](https://phpackages.com/packages/medz-oss-stream-wrapper)
```

###  Alternatives

[iidestiny/flysystem-oss

Flysystem adapter for the Oss storage.

95628.8k29](/packages/iidestiny-flysystem-oss)[alphasnow/aliyun-oss-flysystem

Flysystem adapter for the Aliyun storage

14270.2k8](/packages/alphasnow-aliyun-oss-flysystem)[luoyy/ali-oss-storage

aliyun oss filesystem storage for laravel 10+

1430.7k1](/packages/luoyy-ali-oss-storage)

PHPackages © 2026

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