PHPackages                             apie/storage-metadata - 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. apie/storage-metadata

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

apie/storage-metadata
=====================

Composer package of the apie library: storage metadata

1.0.0.x-dev(1mo ago)06.8k1MITPHPPHP &gt;=8.3

Since Mar 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/apie-lib/storage-metadata)[ Packagist](https://packagist.org/packages/apie/storage-metadata)[ RSS](/packages/apie-storage-metadata/feed)WikiDiscussions main Synced 1mo ago

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

[![](https://raw.githubusercontent.com/apie-lib/apie-lib-monorepo/main/docs/apie-logo.svg)](https://raw.githubusercontent.com/apie-lib/apie-lib-monorepo/main/docs/apie-logo.svg)

storage-metadata
================

[](#storage-metadata)

[![Latest Stable Version](https://camo.githubusercontent.com/bd3a4909b74e96968146dfe1233ae99fda41a086d197263730a828c2724b30f4/68747470733a2f2f706f7365722e707567782e6f72672f617069652f73746f726167652d6d657461646174612f76)](https://packagist.org/packages/apie/storage-metadata) [![Total Downloads](https://camo.githubusercontent.com/a37c7f8e4f8070080d20b1ab9bf74b390fb263c6118b9906f3fd706d16e3a0a6/68747470733a2f2f706f7365722e707567782e6f72672f617069652f73746f726167652d6d657461646174612f646f776e6c6f616473)](https://packagist.org/packages/apie/storage-metadata) [![Latest Unstable Version](https://camo.githubusercontent.com/1db8c3764c02f43d4551af9604cc33d553bb8b0b86775a64237c4517825ed114/68747470733a2f2f706f7365722e707567782e6f72672f617069652f73746f726167652d6d657461646174612f762f756e737461626c65)](https://packagist.org/packages/apie/storage-metadata) [![License](https://camo.githubusercontent.com/67eb2708c0061e116f583bbdb8454246678eb6daa91545f1dca8ef0764dcdf1a/68747470733a2f2f706f7365722e707567782e6f72672f617069652f73746f726167652d6d657461646174612f6c6963656e7365)](https://packagist.org/packages/apie/storage-metadata) [![PHP Composer](https://camo.githubusercontent.com/bf8a5d08cd7dfa8da00a5a56155e979c1e852c5c94c71e7a4528667f7c664464/68747470733a2f2f617069652d6c69622e6769746875622e696f2f70726f6a656374436f7665726167652f636f7665726167652d73746f726167652d6d657461646174612e737667)](https://apie-lib.github.io/projectCoverage/storage-metadata/index.html)

[![PHP Composer](https://github.com/apie-lib/storage-metadata/actions/workflows/php.yml/badge.svg?event=push)](https://github.com/apie-lib/storage-metadata/actions/workflows/php.yml)

This package is part of the [Apie](https://github.com/apie-lib) library. The code is maintained in a monorepo, so PR's need to be sent to the [monorepo](https://github.com/apie-lib/apie-lib-monorepo/pulls)

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

[](#documentation)

This package is used to convert an Apie domain object to a storage DTO that can be used by data mapper ORM's. The creation of a storage DTO can be done by hand or created automatically by the package [apie/storage-metadata-builder](https://packagist.org/packages/apie/storage-metadata-builder).

### Usage

[](#usage)

The simplest usage is using the simple static create method. In case you want to customize it you can create the object yourself.

```
use Apie\Core\FileStorage\FileStorageFactory;
use Apie\StorageMetadata\DomainToStorageConverter;

DomainToStorageConverter::create(FileStorageFactory::create());
```

A file storage service is required to store properties with typehints of UploadedFileInterface or StoredFile, since you do not want to store your files in the database (this is still possible with InlineStorage, but that should only be used for testing).

An Indexer service can also be provided for how indexing search indexes and columns.

You need a domain object and a storage DTO. For example this could be how your storage DTO looks like for an Address object that is part of an User object:

```
use Apie\StorageMetadata\Attributes\ParentAttribute;
use Apie\StorageMetadata\Attributes\PropertyAttribute;
use Apie\StorageMetadata\Interfaces\StorageDtoInterface;
use ReflectionClass;

class AddressStorage implements StorageDtoInterface
{
    public static function getClassReference(): ReflectionClass
    {
        return new ReflectionClass(Address::class);
    }

    #[ParentAttribute]
    public User $parent;
    public function __construct(
        #[PropertyAttribute('street')]
        public ?string $apieStreet,
        #[PropertyAttribute('streetNumber')]
        public ?string $apieStreetNumber,
        #[PropertyAttribute('zipcode')]
        public ?string $apieZipcode,
        #[PropertyAttribute('city')]
        public ?string $apieCity,
        #[PropertyAttribute('manual')]
        public ?bool $apieManual,
    ) {
    }
}
```

Then you can convert a domain object to a storage object or vice versa. It's also possible to inject in existing records.

```
use Apie\Core\FileStorage\FileStorageFactory;
use Apie\StorageMetadata\DomainToStorageConverter;

$converter = DomainToStorageConverter::create(FileStorageFactory::create());
$domainObject = $converter->createDomainObject(
    new AddressStorage(
        'Evergreen Terrace',
        '742',
        '11111',
        'Springfield',
        false
    )
);
```

This example creates a Address domain object with street, zipcode, city and manual property filled in.

### Polymorphic resources

[](#polymorphic-resources)

Polymorphic resources are mapped as well, but you need to provide a second argument to PropertyAttribute to define the mapped class. Basically if the property is not mapped to this domain object null will be stored in the column.

```
use Apie\Core\Utils\EntityUtils;
use Apie\StorageMetadata\Attributes\DiscriminatorMappingAttribute;
use Apie\StorageMetadata\Attributes\GetMethodAttribute;
use Apie\StorageMetadata\Attributes\PropertyAttribute;
use Apie\StorageMetadata\Interfaces\StorageClassInstantiatorInterface;

class AnimalStorage implements StorageClassInstantiatorInterface
{
    public function __construct(
        #[DiscriminatorMappingAttribute]
        private array $discriminatorMapping,
        #[GetMethodAttribute('getId')]
        private string $id,
        #[PropertyAttribute('id')]
        private ?string $apieId,
        #[PropertyAttribute('hasMilk', Cow::class)]
        private ?bool $apieHasMilk = null,
        #[PropertyAttribute('starving', Elephant::class)]
        private ?bool $apieStarving = null,
        #[PropertyAttribute('poisonous', Fish::class)]
        private ?bool $apiePoisonous = null
    ) {
    }

    public static function getClassReference(): ReflectionClass
    {
        return new ReflectionClass(Animal::class);
    }

    public function createDomainObject(ReflectionClass $class): object
    {
        $class = EntityUtils::findClass($this->discriminatorMapping, $class);
        assert(null !== $class);
        return $class->newInstanceWithoutConstructor();
    }
}
```

This example also shows how to make the domain object first as you can not instantiate a base abstract class like without knowing how to map it (this works with the DiscriminatorMappingAttribute attribute).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

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 ~376 days

Total

2

Last Release

50d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/apie-storage-metadata/health.svg)

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15161.6M2.6k](/packages/illuminate-filesystem)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)[madnest/madzipper

Easier zip file handling for Laravel applications.

1382.3M6](/packages/madnest-madzipper)

PHPackages © 2026

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