PHPackages                             yii2-uploader/storage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. yii2-uploader/storage

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

yii2-uploader/storage
=====================

This version is minify from yii2 kit file to remove unnecessary jquery, css ui in the api template\\

v1.0(3y ago)111PHP

Since Mar 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/khuongdev2001/yii2-file-kit-minify-storage)[ Packagist](https://packagist.org/packages/yii2-uploader/storage)[ RSS](/packages/yii2-uploader-storage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

[![Packagist Version (custom server)](https://camo.githubusercontent.com/207bae092a5b6969c63e2b996c86c5ae2d717768cc06e47f118189df4dd48a57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796969322d75706c6f616465722f73746f72616765)](https://camo.githubusercontent.com/207bae092a5b6969c63e2b996c86c5ae2d717768cc06e47f118189df4dd48a57/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796969322d75706c6f616465722f73746f72616765) [![Packagist](https://camo.githubusercontent.com/03d8a5003735ab502176fb0f4eb8cc0703cd3b52d0cd7d663e16225f7cb5b608/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f796969322d737461727465722d6b69742f796969322d66696c652d6b6974)](https://camo.githubusercontent.com/03d8a5003735ab502176fb0f4eb8cc0703cd3b52d0cd7d663e16225f7cb5b608/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f796969322d737461727465722d6b69742f796969322d66696c652d6b6974)

This kit is designed to automate routine processes of uploading files, their saving and storage. and motify from yii2-file-kit remove css, jquery remove unnecessary libraries running on rest

Here you can see list of available [filesystem adapters](https://github.com/thephpleague/flysystem#adapters)

Installation
============

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require yii2-uploader/storage

```

or add

```
"yii2-uploader/storage": "@v1.0"

```

to the require section of your `composer.json` file.

File Storage
============

[](#file-storage)

To work with the File Kit you need to configure FileStorage first. This component is a layer of abstraction over the filesystem

- Its main task to take on the generation of a unique name for each file and trigger corresponding events.

```
'fileStorage'=>[
    'class' => 'trntv\filekit\Storage',
    'useDirindex' => true,
    'baseUrl' => '@web/uploads'
    'filesystem'=> ...
        // OR
    'filesystemComponent' => ...
],
```

There are several ways to configure `trntv\filekit\Storage` to work with `flysystem`.

Using Closure
-------------

[](#using-closure)

```
'fileStorage'=>[
    ...
    'filesystem'=> function() {
        $adapter = new \League\Flysystem\Adapter\Local('some/path/to/storage');
        return new League\Flysystem\Filesystem($adapter);
    }
]
```

Using filesystem builder
------------------------

[](#using-filesystem-builder)

- Create a builder class that implements `trntv\filekit\filesystem\FilesystemBuilderInterface` and implement method `build` which returns filesystem object. See `examples/`
- Add to your configuration:

```
'fileStorage'=>[
    ...
    'filesystem'=> [
        'class' => 'app\components\FilesystemBuilder',
        'path' => '@webroot/uploads'
        ...
    ]
]
```

Read more about flysystem at

Using third-party extensions
----------------------------

[](#using-third-party-extensions)

- Create filesystem component (example uses `creocoder/yii2-flysystem`)

```
'components' => [
    ...
    'fs' => [
        'class' => 'creocoder\flysystem\LocalFilesystem',
        'path' => '@webroot/files'
    ],
    ...
]
```

- Set filesystem component name in storage configuration:

```
'components' => [
    ...
    'fileStorage'=>[
        'filesystemComponent'=> 'fs'
    ],
    ...
]
```

Actions
=======

[](#actions)

File Kit contains several Actions to work with uploads.

### Upload Action

[](#upload-action)

Designed to save the file uploaded by the widget

```
public function actions(){
    return [
           'upload'=>[
               'class'=>'trntv\filekit\actions\UploadAction',
               //'deleteRoute' => 'my-custom-delete', // my custom delete action for deleting just uploaded files(not yet saved)
               //'fileStorage' => 'myfileStorage', // my custom fileStorage from configuration
               'multiple' => true,
               'disableCsrf' => true,
               'responseFormat' => Response::FORMAT_JSON,
               'responsePathParam' => 'path',
               'responseBaseUrlParam' => 'base_url',
               'responseUrlParam' => 'url',
               'responseDeleteUrlParam' => 'delete_url',
               'responseMimeTypeParam' => 'type',
               'responseNameParam' => 'name',
               'responseSizeParam' => 'size',
               'deleteRoute' => 'delete',
               'fileStorage' => 'fileStorage', // Yii::$app->get('fileStorage')
               'fileStorageParam' => 'fileStorage', // ?fileStorage=someStorageComponent
               'sessionKey' => '_uploadedFiles',
               'allowChangeFilestorage' => false,
               'validationRules' => [
                    ...
               ],
               'on afterSave' => function($event) {
                    /* @var $file \League\Flysystem\File */
                    $file = $event->file
                    // do something (resize, add watermark etc)
               }
           ]
       ];
}
```

See additional settings in the corresponding class

### Delete Action

[](#delete-action)

```
public function actions(){
    return [
       'delete'=>[
           'class'=>'trntv\filekit\actions\DeleteAction',
           //'fileStorage' => 'fileStorageMy', // my custom fileStorage from configuration(such as in the upload action)
       ]
    ];
}
```

See additional settings in the corresponding class

### View (Download) Action

[](#view-download-action)

```
public function actions(){
    return [
       'view'=>[
           'class'=>'trntv\filekit\actions\ViewAction',
       ]
    ];
}
```

See additional settings in the corresponding class

Upload Widget
=============

[](#upload-widget)

Standalone usage

```
echo \trntv\filekit\widget\Upload::widget([
    'model' => $model,
    'attribute' => 'files',
    'url' => ['upload'],
    'uploadPath' => 'subfolder', // optional, for storing files in storage subfolder
    'sortable' => true,
    'maxFileSize' => 10 * 1024 * 1024, // 10Mb
    'minFileSize' => 1 * 1024 * 1024, // 1Mb
    'maxNumberOfFiles' => 3, // default 1,
    'acceptFileTypes' => new \yii\web\JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),
    'showPreviewFilename' => false,
    'editFilename' => false,
    'clientOptions' => [/* ...other blueimp options... */]
]);
```

Standalone usage - without model

```
echo \trntv\filekit\widget\Upload::widget([
    'name' => 'filename',
    'hiddenInputId' => 'filename', // must for not use model
    'url' => ['upload'],
    'uploadPath' => 'subfolder', // optional, for storing files in storage subfolder
    'sortable' => true,
    'maxFileSize' => 10 * 1024 * 1024, // 10Mb
    'minFileSize' => 1 * 1024 * 1024, // 1Mb
    'maxNumberOfFiles' => 3, // default 1,
    'acceptFileTypes' => new \yii\web\JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),
    'showPreviewFilename' => false,
    'editFilename' => false,
    'clientOptions' => [/* ...other blueimp options... */]
]);
```

With ActiveForm

```
echo $form->field($model, 'files')->widget(
    '\trntv\filekit\widget\Upload',
    [
        'url' => ['upload'],
        'uploadPath' => 'subfolder', // optional, for storing files in storage subfolder
        'sortable' => true,
        'maxFileSize' => 10 * 1024 * 1024, // 10 MiB
        'maxNumberOfFiles' => 3,
        'clientOptions' => [/* ...other blueimp options... */]
    ]
);
```

Upload Widget events
--------------------

[](#upload-widget-events)

Upload widget trigger some of built-in blueimp events:

- start
- fail
- done
- always

You can use them directly or add your custom handlers in options:

```
'clientOptions' => [
    'start' => new JsExpression('function(e, data) { ... do something ... }'),
    'done' => new JsExpression('function(e, data) { ... do something ... }'),
    'fail' => new JsExpression('function(e, data) { ... do something ... }'),
    'always' => new JsExpression('function(e, data) { ... do something ... }'),
 ]
```

UploadBehavior
==============

[](#uploadbehavior)

This behavior is designed to save uploaded files in the corresponding relation.

Somewhere in model:

For multiple files

```
 public function behaviors()
 {
    return [
        'file' => [
            'class' => 'trntv\filekit\behaviors\UploadBehavior',
            'filesStorage' => 'myfileStorage', // my custom fileStorage from configuration(for properly remove the file from disk)
            'multiple' => true,
            'attribute' => 'files',
            'uploadRelation' => 'uploadedFiles',
            'pathAttribute' => 'path',
            'baseUrlAttribute' => 'base_url',
            'typeAttribute' => 'type',
            'sizeAttribute' => 'size',
            'nameAttribute' => 'name',
            'orderAttribute' => 'order'
        ],
    ];
 }
```

For single file upload

```
 public function behaviors()
 {
     return [
          'file' => [
              'class' => 'trntv\filekit\behaviors\UploadBehavior',
              'filesStorage' => 'fileStorageMy', // my custom fileStorage from configuration(for properly remove the file from disk)
              'attribute' => 'file',
              'pathAttribute' => 'path',
              'baseUrlAttribute' => 'base_url',
               ...
          ],
      ];
 }
```

See additional settings in the corresponding class.

Validation
==========

[](#validation)

There are two ways you can perform validation over uploads. On the client side validation is performed by Blueimp File Upload. Here is [documentation](https://github.com/blueimp/jQuery-File-Upload/wiki/Options#validation-options) about available options.

On the server side validation is performed by \[\[yii\\web\\UploadAction\]\], where you can configure validation rules for \[\[yii\\base\\DynamicModel\]\] that will be used in validation process

Tips
====

[](#tips)

Adding watermark
----------------

[](#adding-watermark)

Install `intervention/image` library

```
composer require intervention/image

```

Edit your upload actions as so

```
public function actions(){
    return [
           'upload'=>[
               'class'=>'trntv\filekit\actions\UploadAction',
               ...
               'on afterSave' => function($event) {
                    /* @var $file \League\Flysystem\File */
                    $file = $event->file;

                    // create new Intervention Image
                    $img = Intervention\Image\ImageManager::make($file->read());

                    // insert watermark at bottom-right corner with 10px offset
                    $img->insert('public/watermark.png', 'bottom-right', 10, 10);

                    // save image
                    $file->put($img->encode());
               }
               ...
           ]
       ];
}

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/278411e776dbb14d0ccf21d195fc073149c5bb30df2f6083722f5f70d573639d?d=identicon)[khuongdev2001](/maintainers/khuongdev2001)

---

Top Contributors

[![khuongdev2001](https://avatars.githubusercontent.com/u/70829682?v=4)](https://github.com/khuongdev2001 "khuongdev2001 (5 commits)")

---

Tags

yii2-file-kit-minify

### Embed Badge

![Health badge](/badges/yii2-uploader-storage/health.svg)

```
[![Health](https://phpackages.com/badges/yii2-uploader-storage/health.svg)](https://phpackages.com/packages/yii2-uploader-storage)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M87](/packages/league-flysystem-bundle)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
