hedii/laravel-ovh-swift-storage 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hedii/laravel-ovh-swift-storage

Composer 安装命令:

composer require hedii/laravel-ovh-swift-storage

包简介

Out of the box Ovh Swift storage usage for Laravel

README 文档

README

Build Status Total Downloads License Latest Stable Version

Laravel Ovh Swift Storage

Out of the box Ovh Swift storage usage for Laravel 6.0+

Table of contents

Installation

Install via composer

composer require hedii/laravel-ovh-swift-storage

Edit config/filesystems.php to add the new ovh-swift disk

return [

    'disks' => [
        /* ... */

        'ovh-swift' => [
            'driver' => 'ovh-swift',
            'authUrl' => env('OVH_SWIFT_OPENSTACK_AUTH_URL', 'https://auth.cloud.ovh.net/v3/'),
            'region' => env('OVH_SWIFT_OPENSTACK_REGION'),
            'projectId' => env('OVH_SWIFT_OPENSTACK_PROJECT_ID'),
            'containerName' => env('OVH_SWIFT_CONTAINER_NAME'),
            'prefix' => env('OVH_SWIFT_PREFIX'),
            'username' => env('OVH_SWIFT_OPENSTACK_USERNAME'),
            'password' => env('OVH_SWIFT_OPENSTACK_PASSWORD'),
            'visibility' => env('OVH_SWIFT_VISIBILITY', 'public'),
            'publicUrl' => env('OVH_SWIFT_PUBLIC_URL'),
            'urlKey' => env('OVH_SWIFT_URL_KEY'),
            'requestOptions' => [],
        ],
    
    ],

];

Edit .env to add the required environment variables

OVH_SWIFT_OPENSTACK_REGION=GRA
OVH_SWIFT_OPENSTACK_PROJECT_ID=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_CONTAINER_NAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_USERNAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_PASSWORD=xxxxxxxxxxxxxxxxxxx

Usage

Once you have modified the Laravel filesystem configuration and the environment variables, you can use the new Ovh Swift storage disk as any Laravel storage disk.

Private containers

By default, this package assumes you are using a public Object Storage container.

If you want to use a private container with temporary urls, you have to configure a temporary url key and set the visibility to private.

OVH_SWIFT_OPENSTACK_REGION=GRA
OVH_SWIFT_OPENSTACK_PROJECT_ID=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_CONTAINER_NAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_USERNAME=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_OPENSTACK_PASSWORD=xxxxxxxxxxxxxxxxxxx
OVH_SWIFT_VISIBILITY=private
OVH_SWIFT_URL_KEY=xxxxxxxxxxxxxxxxxxx

Be aware you will not be able to retrieve regular urls with a private container, only temporary urls.

Request options

If you want to use http request options like timeout, connect_timeout or any other valid option, put them in the driver configuration.

return [

    'disks' => [
        /* ... */

        'ovh-swift' => [
            /* ... */
            'requestOptions' => [
                'timeout' => 3.14,
                'connect_timeout' => 3.14,
            ],
        ],
    
    ],

];

Example

use Illuminate\Support\Facades\Storage;

Storage::disk('ovh-swift')->put('avatars/1', $fileContents);

$url = Storage::url('avatars/1');

// if using private containers:
$temporaryUrl = Storage::temporaryUrl('avatars/1', now()->addMinute());

Testing

If you want to test the package, you must create a new Openstack user and two new Ovh Object Storage containers:

  • A public container named test
  • A private container named test-private

Once it's done, copy phpunit.xml.dist to phpunit.xml and update the environment variables.

Be aware that the test suite will delete all files in the containers after each test. Do not test against a production containers!

To start test suite, run this command:

composer test

License

laravel-ovh-swift-storage is released under the MIT Licence. See the bundled LICENSE file for details.

hedii/laravel-ovh-swift-storage 适用场景与选型建议

hedii/laravel-ovh-swift-storage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 904 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「filesystem」 「storage」 「Openstack」 「swift」 「laravel」 「ovh」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hedii/laravel-ovh-swift-storage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hedii/laravel-ovh-swift-storage 我们能提供哪些服务?
定制开发 / 二次开发

基于 hedii/laravel-ovh-swift-storage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 904
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-31