PHPackages                             thanatosxia/yii2-oss - 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. thanatosxia/yii2-oss

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

thanatosxia/yii2-oss
====================

Aliyun Oss SDK for yii2, based on aliyun/aliyun-oss-php-sdk

1.2.8(7y ago)4596[1 issues](https://github.com/thanatos915/yii2-oss/issues)MITPHPPHP &gt;=5.6

Since May 2Pushed 7y ago2 watchersCompare

[ Source](https://github.com/thanatos915/yii2-oss)[ Packagist](https://packagist.org/packages/thanatosxia/yii2-oss)[ RSS](/packages/thanatosxia-yii2-oss/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (12)Used By (0)

Aliyun Oss Sdk Extension for Yii 2
==================================

[](#aliyun-oss-sdk-extension-for-yii-2)

based on [aliyun/aliyun-oss-php-sdk](https://github.com/aliyun/aliyun-oss-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/d3c05fe1613efe98e834f06c1f11db80d93d1e345277c32315b6bd6c49ba8392/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d6f73732f762f737461626c65)](https://packagist.org/packages/thanatosxia/yii2-oss)[![Total Downloads](https://camo.githubusercontent.com/e1a02f0b760f4c38c0ae7fac6a45184fd02b121b0b73ae8da58e9a43adc0aeab/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d6f73732f646f776e6c6f616473)](https://packagist.org/packages/thanatosxia/yii2-oss)[![Latest Unstable Version](https://camo.githubusercontent.com/054576f06fa5d319a57b222896095c5b40710d1fce42907c141c61d68b1d3109/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d6f73732f762f756e737461626c65)](https://packagist.org/packages/thanatosxia/yii2-oss)

安装
--

[](#安装)

```
composer require thanatosxia/yii2-oss
```

使用
--

[](#使用)

添加Oss组件

```
'oss' => [
    'class' => 'thanatos\oss\Oss',
    'accessKeyId' => '', // Your accessKeyId
    'accessKeySecret' => '', // Your accessKeySecret
    'endpoint' => '', // endpoint address
    'bucket' => '', // Bucket Name
],
```

上传文件

```
/**
 * $object 目标文件名
 * $content 二进制文件内容
 * $options 其它参数
 */
Yii::$app->oss->putObject($object, $content, $options);
```

删除文件

```
/**
 * $object 目标文件名
 * $options 其它参数
 */
Yii::$app->oss->deleteObject($object, $options);
```

添加了可以上传远程文件, 可以直接使用，上传远程文件

```
Yii::$app->oss->putObjectOrigin($object, $url, $options);
```

在WEB上传，php回调处理文件

```
// 配置文件中增加一下选项
'oss' => [
    'accessKeyId' => 'xxxx',
    'accessKeySecret' => 'xxxx',
    'endpoint' => 'xxx',
    'bucket' => '',
    'callbackUrl' => '上传成功OSS请求的路径',
    // 自定义的上传回掉的参数
    'callbackParams' => [
        'user_id',
        'method',
        'folder_id'
    ]
],

// 获取OSS 签名 (dir 是允许前端上传的目录前缀)
return Yii::$app->oss->getSignature($dir);
```

说明
--

[](#说明)

Oss 类重新分装了官方的类，官方类中一切方法均可使用，在中间加入了单例机制，和规范的返回值。 原使用方式

```
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->putObject($bucket, $object, $content);
```

现在使用方式

```
Yii::$app->oss->putObject($object, $content, $options);
```

如有需要操作多个Bucket的情况，重置Bucket后操作

```
Yii::$app->oss->setBucket($bucket);
Yii::$app->oss->putObject($object, $content, $options);
```

Think you use this package!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~8 days

Recently: every ~1 days

Total

11

Last Release

2849d ago

### Community

Maintainers

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

---

Top Contributors

[![thanatos915](https://avatars.githubusercontent.com/u/19340332?v=4)](https://github.com/thanatos915 "thanatos915 (41 commits)")

### Embed Badge

![Health badge](/badges/thanatosxia-yii2-oss/health.svg)

```
[![Health](https://phpackages.com/badges/thanatosxia-yii2-oss/health.svg)](https://phpackages.com/packages/thanatosxia-yii2-oss)
```

###  Alternatives

[mihaildev/yii2-elfinder

Yii2 ElFinder

169658.8k52](/packages/mihaildev-yii2-elfinder)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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