2017 © Pedro Peláez
 

yii2-extension yii2-multifs

Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems.

image

insolita/yii2-multifs

Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems.

  • Friday, November 3, 2017
  • by Insolita
  • Repository
  • 2 Watchers
  • 3 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Multifs Manager

  • Provide Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems (League\Flysystem\Filesystem);
  • Provide flexible Uploader service with support different strategies for resolve file naming, file path structure, and file saving
  • Provide sample Upload,View and Delete Actions with output compatible with trntv\filekit\widget\Upload

Status, (*1)

Installation

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

Either run, (*3)

composer require --prefer-dist insolita/yii2-multifs "~1.0.0"

or add, (*4)

"insolita/yii2-multifs": "~0.0.1"

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

Usage

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

Define in bootstrap neccessary filesystems, (*7)

 $avatars = (new \insolita\multifs\builders\LocalFsBuilder('@app/web/uploads/avatars'))->build();
 $covers = (new \insolita\multifs\builders\LocalFsBuilder('@app/web/uploads/covers'))->build();
 $attach = (new \insolita\multifs\builders\LocalFsBuilder('@app/web/uploads/attach'))->build();
 $data = (new \insolita\multifs\builders\LocalFsBuilder('@data'))->build();

(Ensure that aliases already defined), (*8)

Register in container:, (*9)

 \insolita\multifs\contracts\IMultifsManager::class                                              => [
                \insolita\multifs\MultiFsManager::class,
                [
                    [
                        'avatars'  => $avatars,
                        'covers'   => $covers,
                        'attach'   => $attach,
                        'internal' => $data,
                    ],
                ],
            ],
            \insolita\multifs\contracts\IUploader::class=>[
                \insolita\multifs\Uploader::class,
                [
                    \yii\di\Instance::of(\insolita\multifs\contracts\IMultifsManager::class),
                    'attach'
                ]
            ],

also you can add components aliases, (*10)

```php, (*11)

'components'=>[ 'multifs'=>\insolita\multifs\contracts\IMultifsManager::class, 'uploader'=>\insolita\multifs\contracts\IUploader::class, ] ```, (*12)

On fly usage, (*13)

```php, (*14)

  echo Yii::$app->multifs->listPrefixes();
  Yii::$app->multifs->mountFilesystem('special', new Filesystem(new Adapter(...)));
  Yii::$app->multifs->write('special://some/file/path/name.txt','Hello Test');
  $fs = Yii::$app->multifs->getFilesystem('internal');
  Vardumper::dump($fs->listConents('',true));

```, (*15)

Uploader, (*16)

```php, (*17)

 $file = \yii\web\UploadedFile::getInstanceByName('file');
 $path = Yii::$app->uploader->setFsPrefix('avatars')
           ->setFileNameStrategy(new insolita\multifs\strategy\filename\AsIsStrategy())
           ->setFilePathStrategy(new insolita\multifs\strategy\filename\NameHashStrategy())
           ->setFileSaveStrategy(new insolita\multifs\strategy\filename\ExceptionSaveExistsStrategy())
           ->save($file);

\Yii::$app->response->sendStreamAsFile(Yii::$app->multifs->readStream($path),
                                        pathinfo($path, PATHINFO_BASENAME),
                                        [
                                           'mimeType' => $file->getType(),
                                           'inline'=>true
                                        ]);

```, (*18)

Other documentation will be later; see tests, (*19)

The Versions

03/11 2017

dev-master

9999999-dev

Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Insolita

filesystem extension yii2 uploader flysystem

03/11 2017

1.0.0

1.0.0.0

Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Insolita

filesystem yii2 uploader flysystem

04/07 2017

0.0.1

0.0.1.0

Multifs Manager based on (League\Flysystem\MountManager) for work with set of filesystems.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Insolita

filesystem yii2 uploader flysystem