PHPackages                             fsi/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fsi/metadata

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

fsi/metadata
============

FSi Metadata Component is a library that provide some commonly used mechanisms to read configurations for classes from different sources like annotations, yaml or xml.

0.9.3(12y ago)017.9k21MITPHPPHP &gt;=5.3.2

Since Sep 14Pushed 8y ago7 watchersCompare

[ Source](https://github.com/fsi-open/metadata)[ Packagist](https://packagist.org/packages/fsi/metadata)[ RSS](/packages/fsi-metadata/feed)WikiDiscussions master Synced 1w ago

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

THIS PACKAGE IS DEPRECATED
==========================

[](#this-package-is-deprecated)

Do not use this package, as it will not receive any updates and may be deleted in the future.

FSi Metadata Component Documentation
====================================

[](#fsi-metadata-component-documentation)

FSi Metadata Component is a library that provide some commonly used mechanisms to read configurations for classes from different sources like annotations, yaml or xml. At the moment only php files annotations are supported.

Setup and autoloading
---------------------

[](#setup-and-autoloading)

We highly recommend to use autoloader generated by composer.phar

**Adding reflection into composer.json**

```
{
    ...
    "require": {
        ...
        "fsi/metadata": "0.9.*"
        ...
    },
    ...
}

```

Usage
-----

[](#usage)

FSi Metadata Component provides ClassMetadata object that can be easly overwritten. Default ClassMetadata object allows you to strore inside of it configuration for class, properties and methods. This can be done by using methods "addClassMetadata", "addPropertyMetadata", "addMethodMetadata".

What you need to do is to create class that extends from one of abstract drivers like AbstractAnnotationDriver.

Example of reading annotations from php class files.

**Annotation driver**

```
namespace FSi\Bundle\SiteBundle\Metadata\Driver;

use FSi\Component\Metadata\ClassMetadataInterface;
use FSi\Component\Metadata\Driver\AbstractAnnotationDriver;

class AnnotationDriver extends AbstractAnnotationDriver
{
    public function loadClassMetadata(ClassMetadataInterface $metadata)
    {
        $classReflection  = $metadata->getClassReflection();
        $className        = $classReflection->getName();

        $classReflectionProperties = $classReflection->getProperties();
        foreach ($classReflectionProperties as $property) {
            if ($property->getDeclaringClass()->getName() == $className) {
                foreach ($this->getAnnotationReader()->getPropertyAnnotations($property) as $element) {
                    $metadata->addPropertyMetadata($property->name, $element->name, $element->value);
                }
            }
        }
    }
}
```

**Annotation declaration**

```
namespace FSi\Bundle\SiteBundle\Metadata\Mapping\Annotation;

use Doctrine\Common\Annotations\Annotation;

/** @Annotation */
final class Field extends Annotation {
    public $name;
    public $value;
}
```

**Example action in symfony 2 controller**

```
    public function metadataAction()
    {
        $driver = new \FSi\Bundle\SiteBundle\Metadata\Driver\AnnotationDriver($this->get('annotation_reader'));

        $factory = new MetadataFactory($driver);

        $metdata = $factory->getClassMetadata('FSi\Bundle\SiteBundle\Entity\MetaTest');
    }
```

**Example action in symfony 2 controller (with cache)**

All you need to do to implement caching metadata is create the cache object from `Doctrine\Common\Cache` and pass it into `MetadataFactory` constructor. For development purposes we suggest to use `ArrayCache` instead of not using any cache.

```
public function metadataAction()
{
    $cache = new Doctrine\Common\Cache\ApcCache();

    $driver = new \FSi\Bundle\SiteBundle\Metadata\Driver\AnnotationDriver($this->get('annotation_reader'));

    // the third parameter should be used when one cache instance will be used in many metadata factories.
    $factory = new MetadataFactory($driver, $cache, 'cache-prefix');

    $metdata = $factory->getClassMetadata('FSi\Bundle\SiteBundle\Entity\MetaTest');
}
```

Sometimes default `ClassMetadata` is not enough. You can create own class that implements `ClassMetadataInterface` and pass class name into `MetadataFactory` constructor as third parameter.

**Factory constructor example with custom metadata class**

```
$factory = new MetadataFactory($driver, $cache, 'cache-namespace', 'FSi\SiteBundle\Metadata\MyClassMetadata');
```

If you want to use Metadata Component in two separate mechanisms, inside of the same application you should create new `MetatadaFactory` and appropriate driver in each mechanism but cache driver may be the same object each time. It is possible when cache mechanism is used with different prefix and/or metadata class for each factory object.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~196 days

Total

4

Last Release

4404d ago

PHP version history (2 changes)0.9.0PHP &gt;=5.3.0

0.9.1PHP &gt;=5.3.2

### Community

Maintainers

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

---

Top Contributors

[![chives](https://avatars.githubusercontent.com/u/1170578?v=4)](https://github.com/chives "chives (10 commits)")[![partikus](https://avatars.githubusercontent.com/u/1732227?v=4)](https://github.com/partikus "partikus (1 commits)")[![szymach](https://avatars.githubusercontent.com/u/2230556?v=4)](https://github.com/szymach "szymach (1 commits)")

---

Tags

metadatacomponentannotationfsi

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[fsi/datagrid

FSi DataGrid Component

2761.5k2](/packages/fsi-datagrid)

PHPackages © 2026

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