Download the PHP package liip/metadata-parser without Composer

On this page you can find all versions of the php package liip/metadata-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package metadata-parser

Liip Metadata Parser

This project is Open Sourced based on work that we did initially as closed source at Liip, it may be lacking some documentation. If there is anything that you need or have questions about we would love to see you open an issue! :)

This is a parser for building model metadata from PHP classes. The metadata model can then be used to generate code or configuration. For example a serializer or ElasticSearch schema for types.

The metadata is geared toward this use case. PHP level constructs that represent the same information are grouped together: Methods for virtual properties and fields that have the same serialized name, but are valid in different versions.

This extensible parser can process PHP code and annotations or other metadata. You could write your own parsers, but this library comes with support for:

Contributing

If you want to contribute to the project (awesome!!), please read the Contributing Guidelines and adhere to our Code Of Conduct

Where do I go for help?

If you need, open an issue.

Setup

Usage

The Builder::build method is the main entry point to get a ClassMetadata object. The builder accepts an array of Reducer to select which property to use when there are several options. A reducer can lead to drop a property if none of the variants is acceptable. Multiple options for a single field mainly come from the @SerializedName and @VirtualProperty annotations of JMSSerializer:

The ClassMetadata provides all information on a class. Properties have a PropertyType to tell what kind of property they are. Properties that hold another class, are of the type PropertyTypeClass that has the method getClassMetadata() to get the metadata of the nested class. This structure is validated to not contain any infinite recursion.

Property naming strategy

By default, property names will be translated from a camelCased to a lower and snake_cased name (e.g. myProperty becomes my_property). If you want to keep the property name as is, you can change the strategy to identical via the following code:

Handling Edge Cases with @Preferred

This library provides its own annotation in Liip\MetadataParser\Annotation\Preferred to specify which property to use in case there are several options. This can be useful for example when serializing models without specifying a version, when they use different virtual properties in different versions.

Expected Recursion: Working with Flawed Models

JMS annotation

If you are using JMS annotations, you can add the MaxDepth annotation to properties that might be recursive.

The following example will tell the metadata parser that the recursion is expected up to a maximum depth of 3.

Pure PHP

The RecursionChecker accepts a second parameter to specify places where to break recursion. This is useful if your model tree looks like it has recursions but actually does not have them. JMSSerializer always acts on the actual data and therefore does not notice a recursion as long as it is not infinite.

For example, lets say you have a Product that has a field variants which is again list of Product. Those variant products use the same class and therefore have the variants field. However, in real data a variant never contains further variants. To avoid a recursion exception for this example, you would specify:

With this configuration, the ClassMetadata found in the property type for the variants property of the final model will have no field variants, so that code working on the metadata does not need to worry about infinite recursion.

Extending the metadata parser

This library comes with a couple of parsers, but you can write your own to handle custom information specific to your project. Use the PropertyVariationMetadata::setCustomInformation method to add custom data, and use PropertyMetadata::getCustomInformation to read it in your metadata consumers.


All versions of metadata-parser with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-json Version *
doctrine/annotations Version ^1.13 || ^2.0.1
psr/log Version ^1|^2|^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package liip/metadata-parser contains the following files

Loading the files please wait ....