1. Go to this page and download the library: Download liip/metadata-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
liip / metadata-parser example snippets
use Doctrine\Common\Annotations\AnnotationReader;
use Liip\MetadataParser\Builder;
use Liip\MetadataParser\Parser;
use Liip\MetadataParser\RecursionChecker;
use Liip\MetadataParser\ModelParser\JMSParser;
use Liip\MetadataParser\ModelParser\LiipMetadataAnnotationParser;
use Liip\MetadataParser\ModelParser\PhpDocParser;
use Liip\MetadataParser\ModelParser\ReflectionParser;
use Liip\MetadataParser\ModelParser\VisibilityAwarePropertyAccessGuesser;
$parser = new Parser(
new ReflectionParser(),
new PhpDocParser(),
new JMSParser(new AnnotationReader()),
new VisibilityAwarePropertyAccessGuesser(),
new LiipMetadataAnnotationParser(new AnnotationReader()),
);
$recursionChecker = new RecursionChecker(new NullLogger());
$builder = new Builder($parser, $recursionChecker);
use Liip\MetadataParser\Reducer\GroupReducer;
use Liip\MetadataParser\Reducer\PreferredReducer;
use Liip\MetadataParser\Reducer\TakeBestReducer;
use Liip\MetadataParser\Reducer\VersionReducer;
$reducers = [
new VersionReducer('2'),
new GroupReducer(['api', 'detail']),
new PreferredReducer(),
new TakeBestReducer(),
];
$metadata = $builder->build(MyClass::class, $reducers);
use JMS\Serializer\Annotation as JMS;
use Liip\MetadataParser\Annotation as Liip;
class Product
{
/**
* @JMS\Since("2")
* @JMS\Type("string")
*/
public $name;
/**
* @JMS\Until("1")
* @JMS\SerializedName("name")
* @JMS\Type("string")
* @Liip\Preferred
*/
public $legacyName;
}
use JMS\Serializer\Annotation as JMS;
class RecursionModel
{
/**
* @JMS\MaxDepth(3)
* @JMS\Type("RecursionModel")
*/
public $recursion;
}