2017 © Pedro Peláez
 

library metadata

Class/Attribute metadata management component

image

kcs/metadata

Class/Attribute metadata management component

  • Thursday, July 12, 2018
  • by alekitto
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5,862 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 7 % Grown

The README.md

Metadata management library in PHP

Tests codecov, (*1)

Overview

This library provides utilities for metadata loading, management and retrieval for PHP classes, methods and properties., (*2)

Installation

Install with composer, (*3)

$ composer require kcs/metadata

Usage

A metadata factory responsible for retrieving metadatas for a given class.
To create a metadata factory you can implement MetadataFactoryInterface on your own class or extend the AbstractMetadataFactory., (*4)

use Kcs\Metadata\ClassMetadataInterface;
use Kcs\Metadata\Factory\MetadataFactoryInterface;

class Factory implements MetadataFactoryInterface
{
    public function getMetadataFor($class): ClassMetadataInterface
    {
        ...
    }
}
use Kcs\Metadata\ClassMetadataInterface;
use Kcs\Metadata\Factory\AbstractMetadataFactory;

class Factory extends AbstractMetadataFactory
{
    protected function createMetadata(\ReflectionClass $class): ClassMetadataInterface
    {
        return new MyClassMetadata($class);
    }
}

This allows you to specify which implementation of ClassMetadataInterface will be used for your metadata simply extending the createMetadata method., (*5)

If you extend the AbstractMetadataFactory class (or use MetadataFactory class which creates a ClassMetadata instance for class metadatas), you have to create your metadata loader class implementing LoaderInterface., (*6)

use Kcs\Metadata\Loader\LoaderInterface;

class Loader implements LoaderInterface
{
    public function loadClassMetadata(ClassMetadataInterface $classMetadata)
    {
        ...
    }
}

If more than one source is available for your metadata (Annotations, YAMLs, XMLs, etc.) you can use the ChainLoader class, adding your loaders to it., (*7)

Validation

When a metadata is loaded the factory validate method is called with the newly loaded metadata as argument and the Kcs\Metadata\Event\ClassMetadataLoadedEvent event is dispatched (if an event dispatcher is present).
You can extend validate or listen for the metadata loaded event and check for metadata validity. If a validation error occurs you have to throw an InvalidMetadataException., (*8)

Metadata classes

You can extend the provided classes ClassMetadata, MethodMetadata and PropertyMetadata to build your metadata information.
By default, all the public properties are serialized in cache (if cache is present). You can customize this behaviour by extending the __sleep method of the metadata classes, returning an array of serialized properties., (*9)

License

This library is released under the MIT license, (*10)

Contributions

Contributions are always welcome. Feel free to open an issue or submit a PR to improve this library., (*11)

The Versions

12/07 2018

dev-master

9999999-dev

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

12/07 2018

v2.1.1

2.1.1.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

07/01 2018

v2.1.0

2.1.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

01/11 2017

v2.0.0

2.0.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

05/07 2017

v1.5.0

1.5.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

25/11 2016

v1.4.1

1.4.1.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

05/10 2016

v1.4.0

1.4.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

01/10 2016

v1.3.0

1.3.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

22/09 2016

v1.2.2

1.2.2.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

15/09 2016

v1.2.1

1.2.1.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

06/08 2016

v1.2.0

1.2.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

02/03 2016

v1.1.2

1.1.2.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

02/03 2016

v1.1.1

1.1.1.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

20/02 2016

v1.1

1.1.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata

18/02 2016

v1.0

1.0.0.0

Class/Attribute metadata management component

  Sources   Download

MIT

The Requires

  • php >= 5.4.0

 

The Development Requires

by Alessandro Chitolina

xml annotations yaml metadata