johnlui/aliyun-oss
Larablocks Analysis
johnlui/aliyun-oss works with any PHP project: the latest release (v2.2.1, Apr 6, 2017) doesn't depend on Laravel.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- No release in the last 12 months (last: Apr 6, 2017)
- 668 downloads a month (needs 10,000)
- 486 GitHub stars (at least 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Apr 6, 2017.
- No releases in the last 12 months.
- First released: Jan 9, 2015.
- Monthly downloads: 668, up 52% from six months ago.
- 5 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.
| Install | |
|---|---|
composer require johnlui/aliyun-oss |
|
| Latest Version: | v2.2.1 |
| PHP: | >=5.4.0 |
| License: | MIT |
| Last Updated: | Jun 19, 2020 |
| Links: | GitHub · Packagist |
AliyunOSS
___ __ _ ____ _____ _____
/ | / / (_) __ __ __ __ ____ / __ \ / ___/ / ___/
/ /| | / / / / / / / / / / / / / __ \ / / / / \__ \ \__ \
/ ___ | / / / / / /_/ / / /_/ / / / / / / /_/ / ___/ / ___/ /
/_/ |_|/_/ /_/ \__, / \__,_/ /_/ /_/ \____/ /____/ /____/
/____/
AliyunOSS 是阿里云 OSS 官方 SDK 的 Composer 封装,支持任何 PHP 项目,包括 Laravel、Symfony、TinyLara 等等。
适配 Laravel 7 的新包已经发布:AliyunOSS-Laravel7
更新记录
- 2017-03-08
Release v2.0.0v2 发布,在 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: {
"johnlui/aliyun-oss": "~2.0"
}
然后运行 composer update。
② 执行命令安装
运行命令:
composer require johnlui/aliyun-oss:~2.0
使用(以 Laravel 为例)
构建 Service 文件
新建 app/services/OSS.php,内容可参考:OSS.php,然后修改配置:
... ...
private $city = '青岛';
// 经典网络 or VPC
private $networkType = '经典网络';
private $AccessKeyId = '';
private $AccessKeySecret = '';
... ...
放入自动加载
遵循 psr-0 的项目(如Laravel 4、CodeIgniter、TinyLara)中:
在 composer.json 中 autoload -> classmap 处增加配置:
"autoload": {
"classmap": [
"app/services"
]
}
然后运行 composer dump-autoload。
遵循 psr-4 的项目(如 Laravel 5、Symfony)中:
无需配置,保证目录 App/Services 和命名空间 namespace App\Services; 一致即可自动加载。
使用
use App\Services\OSS;
// 在外网上传一个文件并指定 options 如:Content-Type 类型
// 更多 options 见:https://github.com/johnlui/AliyunOSS/blob/master/src/oss/src/Aliyun/OSS/OSSClient.php#L142-L148
OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径', [
'ContentType' => 'application/pdf',
... ...
]);
更多用法等待着你去发现。
Symfony 3 用法示例
如果你正在使用基于 Symfony 创建的第三方应用程序,而又恰好不懂命名空间及 Composer 自动加载,那么看下面就知道本库在 Symfony 中的用法了:
构建 Service 文件
新建 src/AppBundle/Services/OSS.php,内容参考:OSS.php。
修改顶部的命名空间为 namespace AppBundle\Services;。
放入自动加载
无需配置。
使用
use AppBundle\Services\OSS;
OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径');
反馈
有问题请到 http://lvwenhan.com/laravel/425.html 下面留言。
License
除 “版权所有(C)阿里云计算有限公司” 的代码文件外,遵循 MIT license 开源。
Alternatives to johnlui/aliyun-oss
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| v2.2.1 | >=5.4.0 | MIT | |
| v2.2 | >=5.4.0 | MIT | |
| v2.1 | >=5.4.0 | MIT | |
| v2 | >=5.4.0 | MIT | |
| v1.3.6 | >=5.4.0 | MIT | |
| v1.3.5 | >=5.4.0 | MIT | |
| v1.3.4 | >=5.4.0 | MIT | |
| v1.3.3 | >=5.4.0 | MIT | |
| v1.3.2 | >=5.4.0 | MIT | |
| v1.3.1 | >=5.4.0 | MIT | |
| v1.3 | >=5.4.0 | MIT | |
| v1.2 | >=5.4.0 | MIT | |
| v1.1 | >=5.4.0 | MIT | |
| v1.0 | >=5.4.0 | MIT |