Download the PHP package juliangut/mapping without Composer
On this page you can find all versions of the php package juliangut/mapping. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juliangut/mapping
More information about juliangut/mapping
Files in juliangut/mapping
Package mapping
Short Description Base for mapping support
License BSD-3-Clause
Homepage https://github.com/juliangut/mapping
Informations about the package mapping
Mapping
Base mapping parsing library for any kind of project or library.
This library frees you from the most tedious part of mapping parsing by providing a set of functionalities to easily load mappings from PHP's Attributes or files of different formats (PHP, JSON, XML, YAML), so you can focus on the actual parsing of mappings into metadata you can use onwards.
Examples
Examples of packages fully implementing this library can be found at
Installation
Composer
To use yaml files mappings
Usage
Require composer autoload file
Drivers
Should retrieve parsed metadata stored in a specific format
File mapping
Any kind of format that can be returned on an array can be used
There are mapping traits to easily support four types of mapping files:
- DriverInterface::DRIVER_PHP => Jgut\Mapping\Driver\Traits\PhpMappingTrait
- DriverInterface::DRIVER_JSON => Jgut\Mapping\Driver\Traits\JsonMappingTrait
- DriverInterface::DRIVER_XML => Jgut\Mapping\Driver\Traits\XmlMappingTrait
- DriverInterface::DRIVER_YAML => Jgut\Mapping\Driver\Traits\YamlMappingTrait
Attribute mapping
Annotation mapping
Annotations are deprecated and discouraged. Use Attribute mapping instead
Factory
Create your driver factory extending from Jgut\Mapping\Driver\AbstractDriverFactory, it allows to automatically get a mapping driver from mapping sources
Resolver
Given mapping source definitions, metadata resolver will resolve final metadata using a driver factory
It's not mandatory, but highly recommended, to add a PSR-16 cache implementation to metadata resolver, collecting mapping data from annotations and/or files and transforming them into metadata objects can be an intensive operation that benefits vastly of caching
Mapping source
Define where your mapping data is and how it will be parsed
type
one of \Jgut\Mapping\Driver\DriverFactoryInterface constants:DRIVER_ATTRIBUTE
,DRIVER_PHP
,DRIVER_JSON
,DRIVER_XML
,DRIVER_YAML
orDRIVER_ANNOTATION
if no driver, defaults to DRIVER_ATTRIBUTEpath
a string path or array of paths to where mapping files are located (files or directories) REQUIRED if no driverdriver
an already created \Jgut\Mapping\Driver\DriverInterface object required if no type AND path
Annotations
Base AbstractAnnotation class is provided to ease annotations creation.
getDefaultParameter
defines which annotation property is considered the default ("value" by default). In this previous example event
property will be set to "post_deserialize"
Contributing
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
License
See file LICENSE included with the source code for a copy of the license terms.