PHPackages                             mheads/yii-filestorage-active-record - 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. mheads/yii-filestorage-active-record

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

mheads/yii-filestorage-active-record
====================================

1.0.0(1mo ago)06↓90%BSD-3-ClausePHPPHP 8.3 - 8.5

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/mheads-dev/yii-filestorage-active-record)[ Packagist](https://packagist.org/packages/mheads/yii-filestorage-active-record)[ RSS](/packages/mheads-yii-filestorage-active-record/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (32)Versions (3)Used By (0)

mheads/yii-filestorage-active-record
====================================

[](#mheadsyii-filestorage-active-record)

ActiveRecord adapter for [`mheads/yii-filestorage`](https://github.com/mheads-dev/yii-filestorage).

The package provides:

- `ActiveRecordRepository` - a `RepositoryInterface` implementation that stores file metadata through `yiisoft/active-record`.
- `ArFile` - an ActiveRecord file entity for the `mh_filestorage_file` table.
- `#[FileUpload]` - an ActiveRecord event handler that uploads pending files on save and cleans old files on replace/delete.
- `PendingUploadedFileOwnerInterface` and `PendingUploadedFileOwnerTrait` - a small model-side queue for uploaded files.

Physical file storage is still handled by the core package stores, for example `PublicFileSystemStore` and `PrivateFileSystemStore`. The file metadata table schema and `DbRepository` come from `mheads/yii-filestorage-db`, which is installed as a dependency.

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

[](#installation)

```
composer require mheads/yii-filestorage-active-record
```

Also install the database driver used by your project:

```
composer require yiisoft/db-mysql
```

Before using this ActiveRecord adapter, complete the `mheads/yii-filestorage-db` [DB adapter setup](https://github.com/mheads-dev/yii-filestorage-db#installation), including the DB driver and file metadata table. For the demo product table used in examples, see [example migrations](examples/README.md#preparation).

Quick Start
-----------

[](#quick-start)

```
use Mheads\Yii\Filestorage\ActiveRecord\ActiveRecordRepository;
use Mheads\Yii\Filestorage\ActiveRecord\ArFile;
use Mheads\Yii\Filestorage\Storage;
use Mheads\Yii\Filestorage\StorageProvider;
use Yiisoft\Db\Connection\ConnectionProvider;

ConnectionProvider::set($db);

$storage = new Storage(
    repository: new ActiveRecordRepository(ArFile::class),
    stores: [$publicStore],
    defaultStoreName: 'upload',
    defaultGroupName: 'products',
);
StorageProvider::set($storage);

$product = new Product();
$product->setPicture($uploadedFile);
$product->save();
```

`$publicStore` is a core package store, for example `PublicFileSystemStore`. `Product` should use `#[FileUpload]` and `PendingUploadedFileOwnerTrait`; see the lifecycle guide below.

`ConnectionProvider::set()` is required for `ArFile`, `ActiveRecordRepository`, and AR relations. `StorageProvider::set()` is required for `#[FileUpload]` and direct file methods such as `getUrl()`.

See the full flow in [AR file upload lifecycle](docs/guide/en/active-record-file-upload.md) and [02-active-record-file-upload.php](examples/02-active-record-file-upload.php).

Documentation
-------------

[](#documentation)

- [Guide](docs/guide/en/README.md)
- [Examples](examples/README.md)
- [Internals](docs/internals.md)

License
-------

[](#license)

[BSD-3-Clause](LICENSE.md)

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

Every ~0 days

Total

2

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8805360bd6ba1a19f70a9a23819afe7109a80ea0a4c387201f4fa986a50c75f8?d=identicon)[alse0017](/maintainers/alse0017)

---

Top Contributors

[![sa-machineheads](https://avatars.githubusercontent.com/u/22737984?v=4)](https://github.com/sa-machineheads "sa-machineheads (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mheads-yii-filestorage-active-record/health.svg)

```
[![Health](https://phpackages.com/badges/mheads-yii-filestorage-active-record/health.svg)](https://phpackages.com/packages/mheads-yii-filestorage-active-record)
```

###  Alternatives

[olivierbon/craft-squeeze

Zip one or multiple craft assets on the fly for frontend user to download.

137.5k](/packages/olivierbon-craft-squeeze)

PHPackages © 2026

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