2017 © Pedro Peláez
 

yii2-extension yii2-file-system

This extension provides a filesystem solution for Yii 2.

image

callmez/yii2-file-system

This extension provides a filesystem solution for Yii 2.

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 33 Forks
  • 3 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

yii2-file-system

Yii2-file-system是 Flysystem基础上基于 Yii2 框架的实现的扩展。 任何存储,统一的函数调用, (*1)

扩展存储

  • Qinu 七牛云存储

将要实现的功能 (欢迎PR)

  • 阿里云存储
  • 又拍云存储 (未实现大文件流API[还是老牌存储...], 如果实现功能后.大文件操作会有资源要求)
  • 百度云存储
  • 新浪云存储

使用要求

使用教程

使用Componser安装 (以下2种方式)

  • 命令行执行 composer require callmez/yii2-file-system
  • 编辑composer.json, (*2)

    "require": {
      ...
      "callmez/yii2-file-system": "*"
    },
    

编辑配置文件(2种使用方式)

  • 编辑config/main.php, (*3)

    'components' => [
    'fileSystem' => [
      'class' => 'callmez\file\system\Collection',
          'fileSystems' => [
              //根据需求可设置多个存储, 以下来使用例子
              'local' => function() {
                  return new \callmez\file\system\FileSystem(
                      new \callmez\file\system\adapters\Local(\Yii::getAlias('@webroot\images'))
                  );
              },
              'qiniu' => function() {
                  return new \callmez\file\system\FileSystem(
                      new \callmez\file\system\adapters\Qiniu(
                          '七牛空间的 bucket',
                          '七牛空间的 access key',
                          '七牛空间的 access secret',
                          '七牛的空间域名,默认为 {bucket}.qiniu.com 选填'
                      )
                  );
              }
          ]
    ]
    ]
    
  • 使用例子(推荐wrapper方式), (*4)

    // 集合方式
    $local = Yii::$app->fileSystem->get('local');
    $local->write('test.txt', 'hello world');
    echo $local->read('test.txt');
    
    $qiniu = Yii::$app->fileSystem->get('qiniu');
    $qiniu->write('test.txt', 'hello world');
    echo $qiniu->read('test.txt');
    
    // wrapper 方式 (推荐)
    //等同于Yii::$app->fileSystem->get('local')->write('test.txt', 'hello world');
    Yii::$app->fileSystem->write('local://test.txt', 'hello world'); 
    //等同于Yii::$app->fileSystem->get('qiniu')->write('test.txt', 'hello world');
    Yii::$app->fileSystem->write('qiniu://test.txt', 'hello world'); 
    

The Versions

07/07 2015

dev-master

9999999-dev

This extension provides a filesystem solution for Yii 2.

  Sources   Download

MIT

The Requires

 

file yii2 storage qiniu system flysystem

08/12 2014

1.0.1

1.0.1.0

This extension provides a filesystem solution for Yii 2.

  Sources   Download

MIT

The Requires

 

file yii2 storage qiniu system flysystem

08/12 2014

1.0.2

1.0.2.0

This extension provides a filesystem solution for Yii 2.

  Sources   Download

MIT

The Requires

 

file yii2 storage qiniu system flysystem

08/12 2014

1.01

1.01.0.0

This extension provides a filesystem solution for Yii 2.

  Sources   Download

MIT

The Requires

 

file yii2 storage qiniu system flysystem

13/11 2014

1.0

1.0.0.0

This extension provides a filesystem solution for Yii 2.

  Sources   Download

MIT

The Requires

 

file yii2 storage qiniu system flysystem