dev-master
9999999-devFile system Abstraction Layer for Yii2
BSD-3-Clause
The Requires
by Tarun M
file yii2 storage abstraction
Wallogit.com
2017 © Pedro Peláez
File system Abstraction Layer for Yii2
File system Abstraction Layer for Yii2, (*1)
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)
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();
File system Abstraction Layer for Yii2
BSD-3-Clause
file yii2 storage abstraction