PHP Classes

Yii2 MultiFS: File system providers to access configurable paths

Recommend this page to a friend!

  Author Author  
Picture of Insolita
Name: Insolita <contact>
Classes: 19 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 13x


  Detailed description   Download Download .zip .tar.gz  
This package implements file system providers to access configurable paths.

It provides classes that implement PHP file system iterator interfaces that can access directories and files with paths based on configuration values from the YII framework.

The package also provides a file uploading handling that can use the file system classes to implement the processing of files uploaded to a site using these classes.

Details

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

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Define in bootstrap neccessary filesystems

 $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)

Register in container:

 \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


'components'=>[
   'multifs'=>\insolita\multifs\contracts\IMultifsManager::class,
   'uploader'=>\insolita\multifs\contracts\IUploader::class,
]

On fly usage


      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));

Uploader


     $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
                                            ]);

Other documentation will be later; see tests


  Classes of Insolita  >  Yii2 MultiFS  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Yii2 MultiFS
Base name: yii2-multifs
Description: File system providers to access configurable paths
Version: -
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Files and Folders Listing, accessing and manipulating files and folders View top rated classes
Group folder image Libraries Frameworks and libraries of cooperating classes View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 6 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageactions (3 files)
Files folder imagebuilders (3 files)
Files folder imagecontracts (6 files)
Files folder imageentity (4 files)
Files folder imagestrategy (3 directories)
Files folder imageuploader (1 file, 1 directory)
  Plain text file MultiFsManager.php Class Class source
  Plain text file Uploader.php Class Class source

  Files folder image Files  /  src  /  actions  
File Role Description
  Plain text file DeleteAction.php Class Class source
  Plain text file UploadAction.php Class Class source
  Plain text file ViewAction.php Class Class source

  Files folder image Files  /  src  /  builders  
File Role Description
  Plain text file ContextBuilder.php Class Class source
  Plain text file FileUrlManager.php Class Class source
  Plain text file LocalFsBuilder.php Class Class source

  Files folder image Files  /  src  /  contracts  
File Role Description
  Plain text file IContextBuilder.php Class Class source
  Plain text file IFileObject.php Class Class source
  Plain text file IFilesystemBuilder.php Class Class source
  Plain text file IFileUrlManager.php Class Class source
  Plain text file IMultifsManager.php Class Class source
  Plain text file IUploader.php Class Class source

  Files folder image Files  /  src  /  entity  
File Role Description
  Plain text file Context.php Class Class source
  Plain text file UploadedFile.php Class Class source
  Plain text file UploaderErrors.php Class Class source
  Plain text file UploaderResponse.php Class Class source

  Files folder image Files  /  src  /  strategy  
File Role Description
Files folder imagefilename (5 files)
Files folder imagefilepath (5 files)
Files folder imagefilesave (6 files)

  Files folder image Files  /  src  /  strategy  /  filename  
File Role Description
  Plain text file AsIsStrategy.php Class Class source
  Plain text file IFileNameStrategy.php Class Class source
  Plain text file RandomContextPrefixedStrategy.php Class Class source
  Plain text file RandomStringStrategy.php Class Class source
  Plain text file SlugTimeStampedStrategy.php Class Class source

  Files folder image Files  /  src  /  strategy  /  filepath  
File Role Description
  Plain text file ContextNameHashStrategy.php Class Class source
  Plain text file DateStrategy.php Class Class source
  Plain text file DirLimitationStrategy.php Class Class source
  Plain text file IFilePathStrategy.php Class Class source
  Plain text file NameHashStrategy.php Class Class source

  Files folder image Files  /  src  /  strategy  /  filesave  
File Role Description
  Plain text file DeletePreviousExistsStrategy.php Class Class source
  Plain text file ExceptionSaveExistsStrategy.php Class Class source
  Plain text file IFileSaveStrategy.php Class Class source
  Plain text file OverwriteExistsStrategy.php Class Class source
  Plain text file RenameIfNotEqualsStrategy.php Class Class source
  Plain text file RenameOnExistsStrategy.php Class Class source

  Files folder image Files  /  src  /  uploader  
File Role Description
Files folder imageevents (4 files)
  Plain text file BaseUploader.php Class Class source

  Files folder image Files  /  src  /  uploader  /  events  
File Role Description
  Plain text file AfterDeleteUploadEvent.php Class Class source
  Plain text file AfterSaveUploadEvent.php Class Class source
  Plain text file BeforeDeleteUploadEvent.php Class Class source
  Plain text file BeforeSaveUploadEvent.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageconfig (2 files)
Files folder imageunit (10 files)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file bootstrap.php Example Example script
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file yii Example Example script

  Files folder image Files  /  tests  /  config  
File Role Description
  Plain text file base.php Class Class source
  Plain text file console.php Class Class source

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file ActionsTest.php Class Class source
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file CustomContext.php Class Class source
  Plain text file DummyUser.php Class Class source
  Plain text file MultiFsTest.php Class Class source
  Plain text file NameStrategyTest.php Class Class source
  Plain text file PathStrategyTest.php Class Class source
  Plain text file SaveStrategyTest.php Class Class source
  Plain text file TestFsBuildTrait.php Class Class source
  Plain text file UploaderTest.php Class Class source

Download Download all files: yii2-multifs.tar.gz yii2-multifs.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 6 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageactions (3 files)
Files folder imagebuilders (3 files)
Files folder imagecontracts (6 files)
Files folder imageentity (4 files)
Files folder imagestrategy (3 directories)
Files folder imageuploader (1 file, 1 directory)
  Plain text file MultiFsManager.php Class Class source
  Plain text file Uploader.php Class Class source

  Files folder image Files  /  src  /  actions  
File Role Description
  Plain text file DeleteAction.php Class Class source
  Plain text file UploadAction.php Class Class source
  Plain text file ViewAction.php Class Class source

  Files folder image Files  /  src  /  builders  
File Role Description
  Plain text file ContextBuilder.php Class Class source
  Plain text file FileUrlManager.php Class Class source
  Plain text file LocalFsBuilder.php Class Class source

  Files folder image Files  /  src  /  contracts  
File Role Description
  Plain text file IContextBuilder.php Class Class source
  Plain text file IFileObject.php Class Class source
  Plain text file IFilesystemBuilder.php Class Class source
  Plain text file IFileUrlManager.php Class Class source
  Plain text file IMultifsManager.php Class Class source
  Plain text file IUploader.php Class Class source

  Files folder image Files  /  src  /  entity  
File Role Description
  Plain text file Context.php Class Class source
  Plain text file UploadedFile.php Class Class source
  Plain text file UploaderErrors.php Class Class source
  Plain text file UploaderResponse.php Class Class source

  Files folder image Files  /  src  /  strategy  
File Role Description
Files folder imagefilename (5 files)
Files folder imagefilepath (5 files)
Files folder imagefilesave (6 files)

  Files folder image Files  /  src  /  strategy  /  filename  
File Role Description
  Plain text file AsIsStrategy.php Class Class source
  Plain text file IFileNameStrategy.php Class Class source
  Plain text file RandomContextPrefixedStrategy.php Class Class source
  Plain text file RandomStringStrategy.php Class Class source
  Plain text file SlugTimeStampedStrategy.php Class Class source

  Files folder image Files  /  src  /  strategy  /  filepath  
File Role Description
  Plain text file ContextNameHashStrategy.php Class Class source
  Plain text file DateStrategy.php Class Class source
  Plain text file DirLimitationStrategy.php Class Class source
  Plain text file IFilePathStrategy.php Class Class source
  Plain text file NameHashStrategy.php Class Class source

  Files folder image Files  /  src  /  strategy  /  filesave  
File Role Description
  Plain text file DeletePreviousExistsStrategy.php Class Class source
  Plain text file ExceptionSaveExistsStrategy.php Class Class source
  Plain text file IFileSaveStrategy.php Class Class source
  Plain text file OverwriteExistsStrategy.php Class Class source
  Plain text file RenameIfNotEqualsStrategy.php Class Class source
  Plain text file RenameOnExistsStrategy.php Class Class source

  Files folder image Files  /  src  /  uploader  
File Role Description
Files folder imageevents (4 files)
  Plain text file BaseUploader.php Class Class source

  Files folder image Files  /  src  /  uploader  /  events  
File Role Description
  Plain text file AfterDeleteUploadEvent.php Class Class source
  Plain text file AfterSaveUploadEvent.php Class Class source
  Plain text file BeforeDeleteUploadEvent.php Class Class source
  Plain text file BeforeSaveUploadEvent.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageconfig (2 files)
Files folder imageunit (10 files)
  Accessible without login Plain text file .env Data Auxiliary data
  Accessible without login Plain text file bootstrap.php Example Example script
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file yii Example Example script

  Files folder image Files  /  tests  /  config  
File Role Description
  Plain text file base.php Class Class source
  Plain text file console.php Class Class source

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file ActionsTest.php Class Class source
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file CustomContext.php Class Class source
  Plain text file DummyUser.php Class Class source
  Plain text file MultiFsTest.php Class Class source
  Plain text file NameStrategyTest.php Class Class source
  Plain text file PathStrategyTest.php Class Class source
  Plain text file SaveStrategyTest.php Class Class source
  Plain text file TestFsBuildTrait.php Class Class source
  Plain text file UploaderTest.php Class Class source

Download Download all files: yii2-multifs.tar.gz yii2-multifs.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.