Download the PHP package ashleydawson/class-meta without Composer
On this page you can find all versions of the php package ashleydawson/class-meta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ashleydawson/class-meta
More information about ashleydawson/class-meta
Files in ashleydawson/class-meta
Package class-meta
Short Description Add arbitrary metadata to classes and their constants by annotation
License MIT
Informations about the package class-meta
Class Meta
Apply metadata to classes and their constants via annotation. Handy if you need to attach arbitrary data to lookups, enumerations, etc.
Installation
Install ClassMeta via Composer using the following command:
Basic Usage
Apply metadata annotation to classes and constants:
You can now access the metadata using the class meta manager:
Get constant(s) metadata:
Get individual meta by value (i.e. the value of the constant):
Map the collection of constant meta for use in a select drop-down menu, for example:
Note: The optional argument $i
passed to the map closure is the iteration number (starting at 0). Useful if you want to index
the mapped collection instead of returning it as an associative array.
Grouped Metadata
Pass optional arbitrary groups to help organise your metadata:
You can now access groups of metadata like so:
Note: The "Default" group will contain metadata that is not assigned a group
If you need to get meta for all constants, even if they have groups assigned, use the special _all
group name, like so:
Cache
All metadata can be cached by simply passing a valid Doctrine cache provider to the class meta manager:
Cache is invalidated using the class file modify time, but you can also pass an optional TTL in seconds to the ClassMetaManager#setCache()
method:
Tests
To run the ClassMeta test suite, install Composer dev dependencies and run: