2017 © Pedro Peláez
 

yii2-extension yii2-storage

File system Abstraction Layer for Yii2

image

tmukherjee13/yii2-storage

File system Abstraction Layer for Yii2

  • Monday, December 12, 2016
  • by tmukherjee13
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 File Storage

File system Abstraction Layer for Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist tmukherjee13/yii2-storage "*"

or add, (*4)

"tmukherjee13/yii2-storage": "*"

to the require section of your composer.json file., (*5)

Usage

Create a file '_storage.php' inside the config directory of your application with the following contents:, (*6)

<?php
    return [
        'components' => [
           'storage' => [
                'class'  => 'tmukherjee13\storage\S3Storage',
                'bucket' => '<your-s3-bucket-name>',
                'key'    => '<s3-access-key>',
                'secret' => '<s3-secret-key>',
                'region' => '<s3-bucket-region>',
            ]
        ]
    ];

To use your local filesystem as storage use:, (*7)

<?php
    return [
        'components' => [
            'storage' => [
                'class'  => 'tmukherjee13\storage\LocalStorage',
                'path'   => 'uploads', //base directory for storage
                'create' => true,
            ]
        ]
    ];

To write data:, (*8)

$storage = Yii::$app->storage;
$storage->write('dir/file.txt', 'Hello World!',true); // params are: file, content , overwrite

To read data:, (*9)

$file = $storage->get('dir/file.txt');
echo $file->getContent();

The Versions

12/12 2016

dev-master

9999999-dev

File system Abstraction Layer for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Tarun M

file yii2 storage abstraction