kitlabs / kit-oss-bundle

在Symfony中轻松使用阿里云OSS

安装: 38

依赖者: 0

建议者: 0

安全: 0

星标: 5

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

v0.1.8 2017-08-20 15:28 UTC

This package is not auto-updated.

Last update: 2024-09-15 03:49:50 UTC


README

为Symfony3提供的阿里云OSS插件

安装

步骤1:下载插件

打开命令行,进入你的项目目录,然后执行以下命令以下载此插件的最新稳定版本:

$ composer require kitlabs/kit-oss-bundle "~0.1"

此命令需要你全局安装了Composer,具体请参考Composer文档中的安装章节

步骤2:启用插件

然后,通过将其添加到项目中的app/AppKernel.php文件中注册的插件列表来启用该插件。

<?php
// app/AppKernel.php
 
// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
 
            new Kit\Bundle\OssBundle\KitOssBundle(),
        );
 
        // ...
    }
 
    // ...
}

步骤3:配置

# config.yml
kit_oss:
    access_key_id: ************
    access_key_secret: ************
    endpoint: oss-cn-beijing.aliyuncs.com

使用方法

  • 存储桶

      /**
       * @var $bucketService \Kit\Bundle\OssBundle\Service\ossClientService
       */
      $bucketService = $this->get('kit_oss.bucket_service');
      $bucketService->create($bucket);
      $bucketService->getList();
      $bucketService->checkExist($bucket);
    
  • 上传文件

      /**
       *
       * @var \Kit\Bundle\OssBundle\Service\FileService $fileService
       */
      $fileService = $this->container->get('kit_oss.file_service');
      $response = $fileService->upload($file, $bucket, $object, $dir);