PHPackages                             mheads/yii-filestorage-db - 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-db

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

mheads/yii-filestorage-db
=========================

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

Since Jun 4Pushed 1mo agoCompare

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

READMEChangelog (2)Dependencies (30)Versions (3)Used By (1)

mheads/yii-filestorage-db
=========================

[](#mheadsyii-filestorage-db)

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

The package provides `DbRepository`, a `RepositoryInterface` implementation that stores file metadata in a database through `yiisoft/db`. Physical file storage remains the responsibility of the core package stores, for example `PublicFileSystemStore` and `PrivateFileSystemStore`.

Use it when you want the core `Storage` facade with persistent database-backed file metadata.

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

[](#installation)

```
composer require mheads/yii-filestorage-db
```

Also install the database driver used by your project:

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

Apply the migration for `mh_filestorage_file` before adding files:

- [Migrations](docs/guide/en/migrations.md)

For full requirements and supported drivers, see [Prerequisites and installation](docs/guide/en/prerequisites-and-installation.md).

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

[](#quick-start)

```
use Mheads\Yii\Filestorage\Db\DbRepository;
use Mheads\Yii\Filestorage\Storage;
use Mheads\Yii\Filestorage\StorageProvider;
use Mheads\Yii\Filestorage\Store\FileSystem\PublicFileSystemStore;

$repository = new DbRepository($db);

$storage = new Storage(
    repository: $repository,
    stores: [
        new PublicFileSystemStore(
            name: 'upload',
            path: '/app/runtime/upload',
            baseUrl: 'https://cdn.example.com/upload',
        ),
    ],
    defaultStoreName: 'upload',
    defaultGroupName: 'common',
);

StorageProvider::set($storage);
```

```
$file = $storage->add($uploadedFile, groupName: 'products');

$url = $file->getUrl();

$sameFile = $storage->findById($file->getId());
if($sameFile !== null) {
    $storage->remove($sameFile);
}
```

`StorageProvider::set()` is required only when file objects call `getUrl()`, `getContent()`, or `getResource()` directly. If you do not register the provider, call these methods through `Storage` instead.

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

[](#documentation)

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

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community10

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 (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[yiisoft/active-record

Active record pattern implementation

12297.0k18](/packages/yiisoft-active-record)[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)
