PHPackages                             chabberwock/yii2-files - 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. chabberwock/yii2-files

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

chabberwock/yii2-files
======================

Module to handle async file uploads

0.1.2(9y ago)0161BSD-3-ClausePHP

Since Oct 22Pushed 8y ago1 watchersCompare

[ Source](https://github.com/chabberwock/yii2-files)[ Packagist](https://packagist.org/packages/chabberwock/yii2-files)[ Docs](https://github.com/chabberwock/yii2-files)[ RSS](/packages/chabberwock-yii2-files/feed)WikiDiscussions master Synced 4w ago

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

File uploads management module for Yii2
=======================================

[](#file-uploads-management-module-for-yii2)

This module simplifies handling of async uploads. It provides special Session object, that links uploaded files with your model, so you can easily process them later. Based on 2amigos/yii2-file-upload-widget

Installation
------------

[](#installation)

Add "chabberwock/yii2-files": "\*" to "require" section of your composer.json

Once module is installed, add it to modules section of config

```
        'files' => [
            'class' => 'chabberwock\files\Module',
            'uploadDir' => __DIR__ . '/../uploads/temp', // temporary storage dir
            'expires' => 3600, // when old uploaded files should be removed
        ],

```

and to the bootstrap section

```
    'bootstrap' => ['files']

```

Usage
-----

[](#usage)

In view:

```
    // Basic upload

    // Basic plus UI upload

```

Where 'session\_id' is a string attribute. Once model is submitted, session\_id will contain id of session, and can be easily accessed:

```
    $session = Yii::$app->getModule('files')->findSession($model->session_id);
    foreach ($session->listFiles() as $file) {
        $session->moveFile($file, '/public/uploads');
    }

```

Module events
-------------

[](#module-events)

Module generates event on every file upload, that can be used to handle files:

```
        Yii::$app->on('files.upload', function ($event) use ($app) {
            /** @var \chabberwock\files\Session */
            $session = $event->session;
            if (isset($session->meta['target']) && $session->meta['target'] == 'embed') {
                $file = $event->file;
                $newname = uniqid() . '.' . $file->ext;
                $dirParts = [
                    '/uploads/embed',
                    date('Y'),
                    date('m'),
                    date('d'),
                    $newname
                ];
                $path = $app->basePath . implode(DIRECTORY_SEPARATOR, $dirParts);
                if (!file_exists(dirname($path))) {
                    mkdir(dirname($path), 0755, true);
                }
                $session->moveFile($file, $path);
                chmod($path, 0755);
                $file->url = implode('/', $dirParts);
            }
        });

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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

3538d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7067122?v=4)[chabberwock](/maintainers/chabberwock)[@chabberwock](https://github.com/chabberwock)

---

Top Contributors

[![chabberwock](https://avatars.githubusercontent.com/u/7067122?v=4)](https://github.com/chabberwock "chabberwock (11 commits)")[![phplego](https://avatars.githubusercontent.com/u/3162688?v=4)](https://github.com/phplego "phplego (1 commits)")

---

Tags

filesuploadyii2yiiyii 2

### Embed Badge

![Health badge](/badges/chabberwock-yii2-files/health.svg)

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

###  Alternatives

[floor12/yii2-module-files

Yii2 module to upload and manage files to your models.

1612.6k6](/packages/floor12-yii2-module-files)[vova07/yii2-fileapi-widget

The FileAPI widget for Yii2 framework.

4766.0k9](/packages/vova07-yii2-fileapi-widget)[sjaakp/yii2-illustrated-behavior

ActiveRecord Behavior with associated Widget for Yii2.

423.1k](/packages/sjaakp-yii2-illustrated-behavior)[rkit/filemanager-yii2

FileManager for Yii2

181.3k](/packages/rkit-filemanager-yii2)

PHPackages © 2026

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