PHPackages                             wtto/ali-oss-storage - 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. wtto/ali-oss-storage

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

wtto/ali-oss-storage
====================

aliyun oss filesystem storage for laravel 5+

2.3.5(6y ago)0441↓100%MITPHP

Since Aug 11Pushed 5y agoCompare

[ Source](https://github.com/wtto00/Aliyun-oss-storage)[ Packagist](https://packagist.org/packages/wtto/ali-oss-storage)[ Docs](https://github.com/wtto00/Aliyun-oss-storage)[ RSS](/packages/wtto-ali-oss-storage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (19)Used By (0)

Aliyun-oss-storage for Laravel 5+
=================================

[](#aliyun-oss-storage-for-laravel-5)

简体中文 | [English](./readme_en.md)

本仓库 Fork 自 [jacobcyl/Aliyun-oss-storage](https://github.com/jacobcyl/Aliyun-oss-storage)由于作者长时间不更新，所以自己稍微修改下，重新发布。

Aliyun oss filesystem storage adapter for laravel 5. You can use Aliyun OSS just like laravel Storage as usual.
借鉴了一些优秀的代码，综合各方，同时做了更多优化，将会添加更多完善的接口和插件，打造 Laravel 最好的 OSS Storage 扩展

借鉴
--

[](#借鉴)

- [thephpleague/flysystem-aws-s3-v2](https://github.com/thephpleague/flysystem-aws-s3-v2)
- [apollopy/flysystem-aliyun-oss](https://github.com/apollopy/flysystem-aliyun-oss)

依赖
--

[](#依赖)

- Laravel 5+
- `cURL` PHP 扩展

安装
--

[](#安装)

1. 首先运行下面命令来给你的`Laravel`项目安装依赖：

    ```
    composer require wtto/ali-oss-storage
    ```
2. 然后你需要在配置文件`config/app.php`中，添加下边的代码来引用依赖：

    ```
    Wtto\AliOSS\AliOssServiceProvider::class,
    ```

配置
--

[](#配置)

1. 添加下边的代码到配置文件`app/filesystems.php`中：

    ```
    'disks'=>[
        ...
        'oss' => [
            'driver'            => 'oss',
            'access_id'         => env('ALIOSS_KEYID', null), //Your Aliyun OSS AccessKeyId
            'access_key'        => env('ALIOSS_KEYSECRET', null), //Your Aliyun OSS AccessKeySecret
            'bucket'            => env('ALIOSS_BUCKETNAME', null), //OSS bucket name
            'endpoint'          => env('ALIOSS_ENDPOINT', null), // OSS 外网节点或自定义外部域名
            'endpoint_internal' => env('ALIOSS_ENDPOINT_INTERNAL', null), // v2.0.4 新增配置属性，如果为空，则默认使用 endpoint 配置(由于内网上传有点小问题未解决，请大家暂时不要使用内网节点上传，正在与阿里技术沟通中)
            'cdnDomain'         => env('ALIOSS_DOMAIN', null), // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url，如果cdnDomain未设置，则使用endpoint来生成url，否则使用cdn
            'ssl'               => env('ALIOSS_SSL', false), // true to use 'https://' and false to use 'http://'. default is false,
            'isCName'           => env('ALIOSS_CNAME', false), // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url， false: 则使用外部节点生成url
            'debug'             => env('ALIOSS_DEBUG', true),
        ],
        ...
    ]
    ```
2. 然后在文件 `.env` 中配置你的相关信息：

    ```
    FILESYSTEM_DRIVER=oss

    ALIOSS_KEYID=
    ALIOSS_KEYSECRET=
    ALIOSS_BUCKETNAME=
    ALIOSS_ENDPOINT=
    ALIOSS_ENDPOINT_INTERNAL=
    ALIOSS_DOMAIN=
    ALIOSS_SSL=
    ALIOSS_CNAME=
    ALIOSS_DEBUG=
    ```

    > **注意：** 如果你的服务器和你的 OSS Bucket 不在同一个区域的话，请务必不要配置 ALIOSS\_ENDPOINT\_INTERNAL。
    >
    > 如果配置了 ALIOSS\_ENDPOINT\_INTERNAL，那么传输将使用阿里云内网，无论是否配置 ALIOSS\_CNAME 和 ALIOSS\_DOMAIN。
    >
    > **传输优先级：** ALIOSS\_ENDPOINT\_INTERNAL &gt; ALIOSS\_CNAME=true &amp;&amp; ALIOSS\_DOMAIN &gt; ALIOSS\_ENDPOINT。

    好了，这些你就配置完成了。现在你可以像`Laravel Storage`一样使用 `Aliyun OSS` 了。

使用
--

[](#使用)

查看 [Larave doc for Storage](https://laravel.com/docs/5.5/filesystem#custom-filesystems)， 或者你可以按照下边的方式使用：

1. 首先在文件开始位置引用`Laravel Storage`

    ```
    use Illuminate\Support\Facades\Storage;
    ```
2. 然后你就可以使用`Laravel Storage`的`API`了

    ```
    // 如果你设置的默认文件驱动时oss的话，这一步可以跳过
    Storage::disk('oss');

    // 获取目录下所有的文件
    Storage::files($directory);
    // 递归获取目录下所有的文件
    Storage::allFiles($directory);

    // 上传文件 第一个参数是储存位置，第二个参数是文件内容
    Storage::put('path/to/file/file.jpg', $contents);
    // 上传指定本地文件到指定位置
    Storage::putFile('path/to/file/file.jpg', 'local/path/to/local_file.jpg');

    // 获得指定文件的内容
    Storage::get('path/to/file/file.jpg');
    // 判断指定对象是否存在
    Storage::exists('path/to/file/file.jpg');
    // 获得指定对象的大小
    Storage::size('path/to/file/file.jpg');、
    // 获得指定对象的最后修改时间
    Storage::lastModified('path/to/file/file.jpg');

    // 获得指定位置下的所有目录
    Storage::directories($directory);
    // 递归获得指定位置下的所有目录
    Storage::allDirectories($directory);

    // 复制指定对象到指定位置
    Storage::copy('old/file1.jpg', 'new/file1.jpg');
    // 移动指定对象到指定位置
    Storage::move('old/file1.jpg', 'new/file1.jpg');
    // 重命名指定对象
    Storage::rename('path/to/file1.jpg', 'path/to/file2.jpg');

    // 向指定文件中追加前置内容
    Storage::prepend('file.log', 'Prepended Text');
    // 向指定文件中追加内容
    Storage::append('file.log', 'Appended Text');

    // 删除指定对象
    Storage::delete('file.jpg');
    // 删除多个指定对象
    Storage::delete(['file1.jpg', 'file2.jpg']);

    // 创建指定目录
    Storage::makeDirectory($directory);
    // 删除指定目录 目录中的所有文件同样会被删除 请慎重使用
    Storage::deleteDirectory($directory);

    // 更新新添加函数
    // v2.0 添加插件：
    // 上传远程文件到指定位置
    Storage::putRemoteFile('target/path/to/file/jacob.jpg', 'http://example.com/jacob.jpg');
    // v2.0.1 添加插件：
    // 获得指定文件的网址
    Storage::url('path/to/img.jpg'); // get the file url
    // v2.1.1 添加插件：
    // 获得私有 Bucket 的指定文件的临时公开网址 默认临时公开失效是 3600 秒
    Storage::signUrl('path/to/img.jpg',$timeout);
    // v2.3.0 添加插件：
    // 获得指定位置的所有对象 包括目录以及文件 文件会放回相关属性
    Storage::objects($directory);
    // 递归获得指定位置的所有对象 包括目录以及文件 文件会放回相关属性
    Storage::allObjects($directory);
    // v2.3.1 添加插件：
    // 通过url获得文件所在位置
    Storage::url2path($url);
    // 复制目录
    Storage::copyDirectory('path/from/','path/to/');
    // 移动目录
    Storage::moveDirectory('path/from/','path/to/');
    // 重命名目录
    Storage::renameDirectory('path/from/','path/to/');
    // 分页查询指定位置的对象 并返回下一页的标记
    Storage::objects($directory, $page_size = null, $next_marker = '');
    ```

文档
--

[](#文档)

更多开发文档请查看 [Aliyun OSS DOC](https://help.aliyun.com/document_detail/32099.html?spm=5176.doc31981.6.335.eqQ9dM)

许可
--

[](#许可)

源代码是根据 MIT 许可证发布的。有关详细信息，请阅读许可证文件。

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~85 days

Recently: every ~15 days

Total

17

Last Release

2192d ago

Major Versions

1.1.1 → 2.0.02016-11-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/41f1c49c2babc20ae41d670c12bf6afe9144af8b00eb90ca9ac657be7f7a9d88?d=identicon)[wtto00](/maintainers/wtto00)

---

Top Contributors

[![jacobcyl](https://avatars.githubusercontent.com/u/906128?v=4)](https://github.com/jacobcyl "jacobcyl (65 commits)")[![wtto00](https://avatars.githubusercontent.com/u/30424139?v=4)](https://github.com/wtto00 "wtto00 (9 commits)")[![darkicerain](https://avatars.githubusercontent.com/u/6126209?v=4)](https://github.com/darkicerain "darkicerain (2 commits)")[![xsilen](https://avatars.githubusercontent.com/u/59230709?v=4)](https://github.com/xsilen "xsilen (1 commits)")[![jyj1993126](https://avatars.githubusercontent.com/u/6315451?v=4)](https://github.com/jyj1993126 "jyj1993126 (1 commits)")[![chuangbo](https://avatars.githubusercontent.com/u/179978?v=4)](https://github.com/chuangbo "chuangbo (1 commits)")[![Kerry-6](https://avatars.githubusercontent.com/u/26839959?v=4)](https://github.com/Kerry-6 "Kerry-6 (1 commits)")

---

Tags

laravelstoragefilesystemsaliyunoss

### Embed Badge

![Health badge](/badges/wtto-ali-oss-storage/health.svg)

```
[![Health](https://phpackages.com/badges/wtto-ali-oss-storage/health.svg)](https://phpackages.com/packages/wtto-ali-oss-storage)
```

###  Alternatives

[jacobcyl/ali-oss-storage

aliyun oss filesystem storage for laravel 5+

523566.2k7](/packages/jacobcyl-ali-oss-storage)

PHPackages © 2026

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