Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 19 | All time: 11,370 This week: 488![]() |
Version | License | PHP version | Categories | |||
yii2-multifs 1.0 | MIT/X Consortium ... | 5 | PHP 5, Files and Folders, Libraries |
- 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
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | src |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
Class | Class source | ||
![]() |
Class | Class source |
![]() |
/ | src | / | actions |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | builders |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | contracts |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | entity |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | strategy |
![]() |
/ | src | / | strategy | / | filename |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | strategy | / | filepath |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | strategy | / | filesave |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | src | / | uploader |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Class | Class source |
![]() |
/ | src | / | uploader | / | events |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | tests |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Example | Example script |
![]() |
/ | tests | / | config |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | tests | / | unit |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() ![]() |
Aux. | Auxiliary script |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.