2017 © Pedro Peláez
 

yii2-extension yii2-flysystem-wrapper

yii2 flysystem wrapper

image

hossein142001/yii2-flysystem-wrapper

yii2 flysystem wrapper

  • Wednesday, July 11, 2018
  • by hossein142001
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 2 Versions
  • 35 % Grown

The README.md

yii2 flysystem wrapper

yii2 flysystem wrapper. Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one., (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist hossein142001/yii2-flysystem-wrapper "*"

or add, (*4)

"hossein142001/yii2-flysystem-wrapper": "*"

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

then up migrations, (*6)

php yii migrate/up --migrationPath=vendor/hossein142001/yii2-flysystem-wrapper/migrations

Usage/Features

Once the extension is installed, simply use it in your code by :, (*7)

add "fs" to components, (*8)

'fs' => [
    'class' => 'Integral\Flysystem\Adapter\PDOAdapter', // or other adapters
    'tableName' => 'file_storage'
],

upload sample code, (*9)

<?php
$model = new MyModel();
if (Yii::$app->request->isPost) {
    $model->files = UploadedFile::getInstancesByName('files');
    if ($model->validate()) {
        $data = [
            'path' => '@common/files',
            'context' => '025',
            'version' => '1',
            'metadata' => ['meta' => 1, 'meta2' => 2, 'meta3' => 3],
        ];
        return FlysystemWrapper::upload($model->files, $data);
    }
        return $model;
}
?>

note: in model file rule "maxFiles" is required, (*10)

<?php
[['files'], 'file', 'skipOnEmpty' => false, 'maxFiles' => 10, 'extensions' => 'txt, jpg']
?>

get a file by hash key, (*11)

<?php
$hashKey = 'XXX';
return FlysystemWrapper::getByHash($hashKey);
?>

read a file by hash key, (*12)

<?php
$hashKey = 'XXX';
return FlysystemWrapper::readByHash($hashKey);
?>

delete a file by hash key, (*13)

<?php
$hashKey = 'XXX';
return FlysystemWrapper::deleteByHash($hashKey);
?>

note: delete method is logical, (*14)

search file(s) by metadatas or file model spesial attributes, (*15)

<?php
$params = ['meta1' => 1, 'version' => 2];
return FlysystemWrapper::searchByParams($params);
?>

The Versions

11/07 2018

dev-master

9999999-dev

yii2 flysystem wrapper

  Sources   Download

GPL-3.0

The Requires

 

by hossein abaei

file extension yii2 flysystem filemanager flysystem wrapper

29/10 2017

dev-dev

dev-dev

yii2 flysystem wrapper

  Sources   Download

GPL-3.0

The Requires

 

by Ehsan Rezaei

file extension yii2 flysystem filemanager flysystem wrapper