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

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

teddymail/yii2-aliyun-oss
=========================

Yii2 阿里云 OSS

111PHP

Since Mar 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/teddymail/yii2-aliyun-oss)[ Packagist](https://packagist.org/packages/teddymail/yii2-aliyun-oss)[ RSS](/packages/teddymail-yii2-aliyun-oss/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 Aliyun OSS
===============

[](#yii2-aliyun-oss)

Yii2 阿里云 OSS

[![Latest Stable Version](https://camo.githubusercontent.com/280ba022bc344a1408826e22f756d077c73f3cb1334c40f62fe29b3fe921f3dc/68747470733a2f2f706f7365722e707567782e6f72672f74656464796d61696c2f796969322d616c6979756e2d6f73732f762f737461626c65)](https://packagist.org/packages/teddymail/yii2-aliyun-oss)[![Total Downloads](https://camo.githubusercontent.com/874d4e7fb94d513ec8fb895dc644fea69fbfc9d545d15863dfe1a28ec525ed1a/68747470733a2f2f706f7365722e707567782e6f72672f74656464796d61696c2f796969322d616c6979756e2d6f73732f646f776e6c6f616473)](https://packagist.org/packages/teddymail/yii2-aliyun-oss)[![Latest Unstable Version](https://camo.githubusercontent.com/d2c66b0a7c5ffb7fa1c7a8bcbba3977d8729f0024d175dea1725b31879ee1351/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d616c6979756e2d6f73732f762f756e737461626c65)](https://packagist.org/packages/yiier/yii2-aliyun-oss)[![License](https://camo.githubusercontent.com/5cb90cb20045b35614b1d7244ac961c489f629207424426349ef0511706f1d08/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d616c6979756e2d6f73732f6c6963656e7365)](https://packagist.org/packages/yiier/yii2-aliyun-oss)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist teddymail/yii2-aliyun-oss "*"

```

or add

```
"yiier/yii2-aliyun-oss": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

配置文件添加组件 :

```
components => [
    'oss' => [
        'class' => 'teddymail\AliyunOSS\OSS',
        'accessKeyId' => 'xxxxx', // 阿里云OSS AccessKeyID
        'accessKeySecret' => 'xxxx', // 阿里云OSS AccessKeySecret
        'bucket' => 'xxx', // 阿里云的bucket空间
        'lanDomain' => 'oss-cn-hangzhou-internal.aliyuncs.com', // OSS内网地址
        'wanDomain' => 'oss-cn-hangzhou.aliyuncs.com', //OSS外网地址
        'isInternal' => true // 上传文件是否使用内网，免流量费（选填，默认 false 是外网）
    ],
]
```

```
/** @var \yiier\AliyunOSS\OSS $oss */
$oss = \Yii::$app->get('oss');
$fh = '/vagrant/php/baseapi/web/storage/image/824edb4e295892aedb8c49e4706606d6.png';
$oss->upload('824edb4e295892aedb8c49e4706606d6.png', $fh);

或者

$oss->upload('storage/image/824edb4e295892aedb8c49e4706606d6.png', $fh); // 会自动创建文件夹

其他用法

$oss->createDir('storage/image/'); //创建文件夹
$oss->delete('824edb4e295892aedb8c49e4706606d6.png'); // 删除文件
$oss->delete('storage/image/824edb4e295892aedb8c49e4706606d6.png'); // 删除文件，如果这个文件是此文件夹的最后一个文件，则会把文件夹一起删除
$oss->delete('storage/image/'); // 删除文件夹，但是要确保是空文件夹
$oss->getAllObject(); // 获取根目录下的所有文件名，默认是100个
$oss->getAllObject(['prefix' => 'storage/image/']); // 获取 `storage/image/` 目录下的所有文件名，默认是100个
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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/d77665e76d7540232e9af5b1a4dc7a81e454c83bd6c7aed3e7463eaa39547cb3?d=identicon)[iyuekang](/maintainers/iyuekang)

### Embed Badge

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

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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