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

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

juhedata/aliyun-oss
===================

阿里云 OSS 官方 SDK 的 Composer 封装，支持 PHP7.2 项目，包括 Laravel、Symfony、TinyLara 等等。

v2.2.5(4y ago)03.7kMITPHPPHP &gt;=7.2.0

Since Jan 9Pushed 2y agoCompare

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

READMEChangelogDependencies (1)Versions (19)Used By (0)

AliyunOSS
---------

[](#aliyunoss)

```
    ___     __    _                                    ____    _____   _____
   /   |   / /   (_)   __  __  __  __   ____          / __ \  / ___/  / ___/
  / /| |  / /   / /   / / / / / / / /  / __ \        / / / /  \__ \   \__ \
 / ___ | / /   / /   / /_/ / / /_/ /  / / / /       / /_/ /  ___/ /  ___/ /
/_/  |_|/_/   /_/    \__, /  \__,_/  /_/ /_/        \____/  /____/  /____/
                    /____/

```

AliyunOSS 是阿里云 OSS 官方 SDK 的 Composer 封装，支持任何 PHP 项目，包括 Laravel、Symfony、TinyLara 等等。

更新记录
----

[](#更新记录)

- 2024-04-09 `Release v3.0.0` php&gt;8.2
- 2021-10-09 `Release v2.2.5` 修复dispatch参数传递顺序问题(curlmulti:289)
- 2021-01-19 `Release v2.2.4` 修复文件大小写不一致问题
- 2020-10-29 `Release v2.2.3` 添加根据Bucket选择oss城市
- 2017-03-08 `Release v2.0.0` v2 发布，在 API 易用性上进行了大量优化
- 2016-09-12 `Release v1.3.5` 加入文件元信息的设置功能
- 2016-07-20 `Release v1.3.4` 加入文件元信息的获取功能
- 2016-01-31 `Release v1.3.2` 获取指定虚拟文件夹下的所有文件
- 2015-10-23 `Release v1.3` 增加删除、复制、移动文件功能
- 2015-08-07 `Release v1.2` 修复内存泄露 bug
- 2015-01-12 `Release v1.1` 增加内外网配置分离
- 2015-01-09 `Release v1.0` 完善功能，增加 Laravel 框架详细使用教程及代码

安装
--

[](#安装)

安装有两种方式：

### ① 直接编辑配置文件

[](#-直接编辑配置文件)

将以下内容增加到 composer.json：

```
require: {
    "juhedata/aliyun-oss": "^3.0"
}
```

然后运行 `composer update`。

### ② 执行命令安装

[](#-执行命令安装)

运行命令：

```
composer require juhedata/aliyun-oss
```

使用（以 Laravel 为例）
----------------

[](#使用以-laravel-为例)

### 构建 Service 文件

[](#构建-service-文件)

新建 `app/services/OSS.php`，内容可参考：[OSS.php](https://github.com/juhedata/aliyun-oss/blob/master/example/OSS.php)，然后修改配置：

```
... ...

  private $city = '青岛';

  // 经典网络 or VPC
  private $networkType = '经典网络';

  private $AccessKeyId = '';
  private $AccessKeySecret = '';

... ...
```

### 放入自动加载

[](#放入自动加载)

#### 遵循 psr-0 的项目（如Laravel 4、CodeIgniter、TinyLara）中：

[](#遵循-psr-0-的项目如laravel-4codeignitertinylara中)

在 `composer.json` 中 `autoload -> classmap` 处增加配置：

```
"autoload": {
    "classmap": [
      "app/services"
    ]
  }
```

然后运行 `composer dump-autoload`。

#### 遵循 psr-4 的项目（如 Laravel 5、Symfony）中：

[](#遵循-psr-4-的项目如-laravel-5symfony中)

无需配置，保证目录 `App/Services` 和命名空间 `namespace App\Services;` 一致即可自动加载。

### 使用

[](#使用)

```
use App\Services\OSS;

// 在外网上传一个文件并指定 options 如：Content-Type 类型
// 更多 options 见：https://github.com/juhedata/aliyun-oss/blob/master/src/oss/src/Aliyun/OSS/OSSClient.php#L142-L148
OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径', [
    'ContentType' => 'application/pdf',
    ... ...
]);
```

更多用法等待着你去[发现](https://github.com/juhedata/aliyun-oss/blob/master/example/OSS.php)。

### Symfony 3 用法示例

[](#symfony-3-用法示例)

如果你正在使用基于 Symfony 创建的第三方应用程序，而又恰好不懂命名空间及 Composer 自动加载，那么看下面就知道本库在 Symfony 中的用法了：

#### 构建 Service 文件

[](#构建-service-文件-1)

新建 `src/App/Services/OSS.php`，内容参考：[OSS.php](https://github.com/juhedata/aliyun-oss/blob/master/example/OSS.php)。

修改顶部的命名空间为 `namespace App\Services;`。

#### 放入自动加载

[](#放入自动加载-1)

无需配置。

#### 使用

[](#使用-1)

```
use AppBundle\Services\OSS;

OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径');
```

License
-------

[](#license)

除 “版权所有（C）阿里云计算有限公司” 的代码文件外，遵循 [MIT license](http://opensource.org/licenses/MIT) 开源。

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 65.2% 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 ~145 days

Recently: every ~411 days

Total

18

Last Release

1674d ago

Major Versions

v1.3.6 → v2.12017-03-15

PHP version history (2 changes)v1.0PHP &gt;=5.4.0

v2.2.2PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8eaea22e75e1ebee47617e0085720b07829ebfbd14e865878eb1853ecdddacd0?d=identicon)[xwzgit](/maintainers/xwzgit)

---

Top Contributors

[![johnlui](https://avatars.githubusercontent.com/u/2127912?v=4)](https://github.com/johnlui "johnlui (45 commits)")[![juheapis](https://avatars.githubusercontent.com/u/204961774?v=4)](https://github.com/juheapis "juheapis (12 commits)")[![ACmagic](https://avatars.githubusercontent.com/u/6644559?v=4)](https://github.com/ACmagic "ACmagic (2 commits)")[![haogeqiu](https://avatars.githubusercontent.com/u/12930642?v=4)](https://github.com/haogeqiu "haogeqiu (2 commits)")[![xwzgit](https://avatars.githubusercontent.com/u/34053770?v=4)](https://github.com/xwzgit "xwzgit (2 commits)")[![zhukangfeng](https://avatars.githubusercontent.com/u/4588185?v=4)](https://github.com/zhukangfeng "zhukangfeng (2 commits)")[![MrVokia](https://avatars.githubusercontent.com/u/9609834?v=4)](https://github.com/MrVokia "MrVokia (1 commits)")[![yaoshanliang](https://avatars.githubusercontent.com/u/5028569?v=4)](https://github.com/yaoshanliang "yaoshanliang (1 commits)")[![khsing](https://avatars.githubusercontent.com/u/40765?v=4)](https://github.com/khsing "khsing (1 commits)")[![menthe](https://avatars.githubusercontent.com/u/1094543?v=4)](https://github.com/menthe "menthe (1 commits)")

---

Tags

aliyunossAliyunOSS

### Embed Badge

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

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

###  Alternatives

[johnlui/aliyun-oss

阿里云 OSS 官方 SDK 的 Composer 封装，支持任何 PHP 项目，包括 Laravel、Symfony、TinyLara 等等。

501178.3k6](/packages/johnlui-aliyun-oss)[jacobcyl/ali-oss-storage

aliyun oss filesystem storage for laravel 5+

523566.2k7](/packages/jacobcyl-ali-oss-storage)[alphasnow/aliyun-oss-laravel

alibaba cloud object storage service for laravel

182240.7k2](/packages/alphasnow-aliyun-oss-laravel)[johnlui/aliyun-oss-laravel7

阿里云 OSS 官方 SDK 的 Composer 封装，支持任何 PHP 项目，包括 Laravel、Symfony、TinyLara 等等。

347.8k1](/packages/johnlui-aliyun-oss-laravel7)[alphasnow/aliyun-oss-flysystem

Flysystem adapter for the Aliyun storage

14249.2k4](/packages/alphasnow-aliyun-oss-flysystem)[summergeorge/ali-oss-storage

aliyun oss filesystem storage for laravel 5+

3915.5k](/packages/summergeorge-ali-oss-storage)

PHPackages © 2026

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