PHPackages                             syablonskiy/yii2-attachfile - 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. syablonskiy/yii2-attachfile

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

syablonskiy/yii2-attachfile
===========================

Package for attaching files using ajax

1.0.1(7y ago)216MITPHP

Since Jul 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/syablonskiy/yii2-attachfile)[ Packagist](https://packagist.org/packages/syablonskiy/yii2-attachfile)[ RSS](/packages/syablonskiy-yii2-attachfile/feed)WikiDiscussions master Synced today

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

Yii2-attachfile
===============

[](#yii2-attachfile)

Данный модуль предназначен для приклепления файла(ов) к моделям ActiveRecord.

Установка
---------

[](#установка)

1. Установите расширение с помощью Composer выполните в терминале `composer require syablonskiy/yii2-attachfile "^1"`либо добавьте в секцию require в файле composer.json `"syablonskiy/yii2-attachfile": "^1"`
2. Добавьте модуль в конфигурацию вашего web-приложения

```
'modules' => [
        ...
        'attachfile' => [
            'class' => syablonskiy\attachfile\Module::className(),
            'storePath' => 'path/to/upload/folder', //default '@app/uploads'
            'rules' => [
                'extensions' => 'jpg, zip, mp4',
                'maxSize' => 1024*1024,
            ],
            'maxFiles' => 2, //default  '3'
            'tableName' => 'your_table_name', //default 'attachment'
        ],
        ...
]
```

3. Выполните миграцию `php yii migrate --migrationPath=@syablonskiy/attachfile/migrations`
4. Прикрепите поведение к вашей ActiveRecord модели

```
    public function behaviors()
    {
        return [
           \syablonskiy\attachfile\behaviors\AttachmentBehavior::className()
        ];
    }
```

5. Удаление неактуальных файлов В конфигурацию консольного приложения добавьте

```
'modules' => [
        ...
        'attachfile' => [
            'class' => syablonskiy\attachfile\Module::className(),
            'controllerNamespace' => 'syablonskiy\attachfile\commands',
        ],
        ...
]
```

И добавьте в планировщик Cron подобную строку `*/30 * * * * cd /path/to/your/app && /usr/bin/php yii attachfile/cron/delete-files >/dev/null`После этого каждые полчаса будут удаляться загруженные, но неприкрепленные к модели файлы.

Использование
-------------

[](#использование)

1. Для прикрепления файлов, к создаваемой модели, передайте в виджет текущий экземпляр \[\[yii\\widgets\\ActiveForm\]\]

```

```

2. Отображение прикреплённых файлов модели `$model`

```

```

Опция 'allowDeletion' добавляет возможность отмечать файлы для удаления

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Every ~65 days

Total

2

Last Release

2802d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2b8334a7c202431de93710911e2db1cd99792e828b89caf2b14d9b4400cbc72?d=identicon)[serega8989](/maintainers/serega8989)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/syablonskiy-yii2-attachfile/health.svg)

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

###  Alternatives

[mihaildev/yii2-elfinder

Yii2 ElFinder

169658.8k52](/packages/mihaildev-yii2-elfinder)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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