Recommend this page to a friend! |
- 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
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.
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 .zip .tar.gz | > | Support forum | > | Blog | > | Latest changes |
|
Groups | Applications | Files |
Groups |
PHP 5 | Classes using PHP 5 specific features | View top rated classes |
Files and Folders | Listing, accessing and manipulating files and folders | View top rated classes |
Libraries | Frameworks and libraries of cooperating classes | View top rated classes |
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (2 files, 6 directories) | ||||
tests (4 files, 2 directories) | ||||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
codeception.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
actions (3 files) | ||||
builders (3 files) | ||||
contracts (6 files) | ||||
entity (4 files) | ||||
strategy (3 directories) | ||||
uploader (1 file, 1 directory) | ||||
MultiFsManager.php | Class | Class source | ||
Uploader.php | Class | Class source |
Files | / | src | / | actions |
File | Role | Description |
---|---|---|
DeleteAction.php | Class | Class source |
UploadAction.php | Class | Class source |
ViewAction.php | Class | Class source |
Files | / | src | / | builders |
File | Role | Description |
---|---|---|
ContextBuilder.php | Class | Class source |
FileUrlManager.php | Class | Class source |
LocalFsBuilder.php | Class | Class source |
Files | / | src | / | contracts |
File | Role | Description |
---|---|---|
IContextBuilder.php | Class | Class source |
IFileObject.php | Class | Class source |
IFilesystemBuilder.php | Class | Class source |
IFileUrlManager.php | Class | Class source |
IMultifsManager.php | Class | Class source |
IUploader.php | Class | Class source |
Files | / | src | / | entity |
File | Role | Description |
---|---|---|
Context.php | Class | Class source |
UploadedFile.php | Class | Class source |
UploaderErrors.php | Class | Class source |
UploaderResponse.php | Class | Class source |
Files | / | src | / | strategy | / | filename |
File | Role | Description |
---|---|---|
AsIsStrategy.php | Class | Class source |
IFileNameStrategy.php | Class | Class source |
RandomContextPrefixedStrategy.php | Class | Class source |
RandomStringStrategy.php | Class | Class source |
SlugTimeStampedStrategy.php | Class | Class source |
Files | / | src | / | strategy | / | filepath |
File | Role | Description |
---|---|---|
ContextNameHashStrategy.php | Class | Class source |
DateStrategy.php | Class | Class source |
DirLimitationStrategy.php | Class | Class source |
IFilePathStrategy.php | Class | Class source |
NameHashStrategy.php | Class | Class source |
Files | / | src | / | strategy | / | filesave |
File | Role | Description |
---|---|---|
DeletePreviousExistsStrategy.php | Class | Class source |
ExceptionSaveExistsStrategy.php | Class | Class source |
IFileSaveStrategy.php | Class | Class source |
OverwriteExistsStrategy.php | Class | Class source |
RenameIfNotEqualsStrategy.php | Class | Class source |
RenameOnExistsStrategy.php | Class | Class source |
Files | / | src | / | uploader | / | events |
File | Role | Description |
---|---|---|
AfterDeleteUploadEvent.php | Class | Class source |
AfterSaveUploadEvent.php | Class | Class source |
BeforeDeleteUploadEvent.php | Class | Class source |
BeforeSaveUploadEvent.php | Class | Class source |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
config (2 files) | ||||
unit (10 files) | ||||
.env | Data | Auxiliary data | ||
bootstrap.php | Example | Example script | ||
unit.suite.yml | Data | Auxiliary data | ||
yii | Example | Example script |
Files | / | tests | / | config |
File | Role | Description |
---|---|---|
base.php | Class | Class source |
console.php | Class | Class source |
Files | / | tests | / | unit |
File | Role | Description |
---|---|---|
ActionsTest.php | Class | Class source |
bootstrap.php | Aux. | Auxiliary script |
CustomContext.php | Class | Class source |
DummyUser.php | Class | Class source |
MultiFsTest.php | Class | Class source |
NameStrategyTest.php | Class | Class source |
PathStrategyTest.php | Class | Class source |
SaveStrategyTest.php | Class | Class source |
TestFsBuildTrait.php | Class | Class source |
UploaderTest.php | Class | Class source |
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 |
File | Role | Description | ||
---|---|---|---|---|
src (2 files, 6 directories) | ||||
tests (4 files, 2 directories) | ||||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
codeception.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
actions (3 files) | ||||
builders (3 files) | ||||
contracts (6 files) | ||||
entity (4 files) | ||||
strategy (3 directories) | ||||
uploader (1 file, 1 directory) | ||||
MultiFsManager.php | Class | Class source | ||
Uploader.php | Class | Class source |
Files | / | src | / | actions |
File | Role | Description |
---|---|---|
DeleteAction.php | Class | Class source |
UploadAction.php | Class | Class source |
ViewAction.php | Class | Class source |
Files | / | src | / | builders |
File | Role | Description |
---|---|---|
ContextBuilder.php | Class | Class source |
FileUrlManager.php | Class | Class source |
LocalFsBuilder.php | Class | Class source |
Files | / | src | / | contracts |
File | Role | Description |
---|---|---|
IContextBuilder.php | Class | Class source |
IFileObject.php | Class | Class source |
IFilesystemBuilder.php | Class | Class source |
IFileUrlManager.php | Class | Class source |
IMultifsManager.php | Class | Class source |
IUploader.php | Class | Class source |
Files | / | src | / | entity |
File | Role | Description |
---|---|---|
Context.php | Class | Class source |
UploadedFile.php | Class | Class source |
UploaderErrors.php | Class | Class source |
UploaderResponse.php | Class | Class source |
Files | / | src | / | strategy | / | filename |
File | Role | Description |
---|---|---|
AsIsStrategy.php | Class | Class source |
IFileNameStrategy.php | Class | Class source |
RandomContextPrefixedStrategy.php | Class | Class source |
RandomStringStrategy.php | Class | Class source |
SlugTimeStampedStrategy.php | Class | Class source |
Files | / | src | / | strategy | / | filepath |
File | Role | Description |
---|---|---|
ContextNameHashStrategy.php | Class | Class source |
DateStrategy.php | Class | Class source |
DirLimitationStrategy.php | Class | Class source |
IFilePathStrategy.php | Class | Class source |
NameHashStrategy.php | Class | Class source |
Files | / | src | / | strategy | / | filesave |
File | Role | Description |
---|---|---|
DeletePreviousExistsStrategy.php | Class | Class source |
ExceptionSaveExistsStrategy.php | Class | Class source |
IFileSaveStrategy.php | Class | Class source |
OverwriteExistsStrategy.php | Class | Class source |
RenameIfNotEqualsStrategy.php | Class | Class source |
RenameOnExistsStrategy.php | Class | Class source |
Files | / | src | / | uploader | / | events |
File | Role | Description |
---|---|---|
AfterDeleteUploadEvent.php | Class | Class source |
AfterSaveUploadEvent.php | Class | Class source |
BeforeDeleteUploadEvent.php | Class | Class source |
BeforeSaveUploadEvent.php | Class | Class source |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
config (2 files) | ||||
unit (10 files) | ||||
.env | Data | Auxiliary data | ||
bootstrap.php | Example | Example script | ||
unit.suite.yml | Data | Auxiliary data | ||
yii | Example | Example script |
Files | / | tests | / | config |
File | Role | Description |
---|---|---|
base.php | Class | Class source |
console.php | Class | Class source |
Files | / | tests | / | unit |
File | Role | Description |
---|---|---|
ActionsTest.php | Class | Class source |
bootstrap.php | Aux. | Auxiliary script |
CustomContext.php | Class | Class source |
DummyUser.php | Class | Class source |
MultiFsTest.php | Class | Class source |
NameStrategyTest.php | Class | Class source |
PathStrategyTest.php | Class | Class source |
SaveStrategyTest.php | Class | Class source |
TestFsBuildTrait.php | Class | Class source |
UploaderTest.php | Class | Class source |
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.
|