PHPackages                             thenlabs/meta-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. thenlabs/meta-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

thenlabs/meta-parser
====================

001PHP

Since Jul 25Pushed 3y agoCompare

[ Source](https://github.com/thenlabs/meta-parser)[ Packagist](https://packagist.org/packages/thenlabs/meta-parser)[ RSS](/packages/thenlabs-meta-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

MetaParser
==========

[](#metaparser)

Extract metadata from attributes and/or annotations.

#### If you like this project gift us a ⭐.

[](#if-you-like-this-project-gift-us-a-)

---

Installation.
-------------

[](#installation)

```
composer require thenlabs/meta-parser dev-main

```

Usage example.
--------------

[](#usage-example)

```
/**
 * @MyMetadata(data1="value1")
 */
#[MyMetadata(data1: 'value2')]
class MyClass
{
}

$myClass = new ReflectionClass(MyClass::class);

/**
 * Reading from annotations only.
 */
$annotationParser = new ThenLabs\MetaParser\AnnotationParser();
$annotationParserResult = $annotationParser->parse($myClass);

$annotationParserResult->get(MyMetadata::class)->get('data1') === 'value1'; // true

/**
 * Reading from attributes only.
 */
$attributeParser = new ThenLabs\MetaParser\AttributeParser();
$attributeParserResult = $attributeParser->parse($myClass);

$attributeParserResult->get(MyMetadata::class)->get('data1') === 'value2'; // true

/**
 * Reading both.
 */
$parser = new ThenLabs\MetaParser\Parser();
$parserResult = $parser->parse($myClass);

// this returns true becouse attributes override annotations.
$parserResult->get(MyMetadata::class)->get('data1') === 'value2';
```

### Highlights about `ThenLabs\MetaParser\Parser` class.

[](#highlights-about-thenlabsmetaparserparser-class)

#### 1. For read annotations it's necessary to install [Doctrine Annotations](https://www.doctrine-project.org/projects/doctrine-annotations/en/1.13/index.html):

[](#1-for-read-annotations-its-necessary-to-install-doctrine-annotations)

```
$ composer require doctrine/annotations

```

#### 2. The attribute parser require a PHP version grater than 8.0.

[](#2-the-attribute-parser-require-a-php-version-grater-than-80)

#### 3. The `parse()` methods accept an instance of `Reflector`, so that, for parse a method of a class(for example), you can use a `ReflectionMethod` instance.

[](#3-the-parse-methods-accept-an-instance-of-reflector-so-that-for-parse-a-method-of-a-classfor-example-you-can-use-a-reflectionmethod-instance)

Development.
------------

[](#development)

Clone this repository and install the Composer dependencies.

```
$ composer install

```

### Running the tests.

[](#running-the-tests)

All the tests of this project was written with our testing framework [PyramidalTests](https://github.com/thenlabs/pyramidal-tests) wich is based on [PHPUnit](https://phpunit.de).

Run tests:

```
$ composer test

```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff9241f3ee1e25a0a016399ff1ae829fea13ed7493c62627ac5068ae61c39197?d=identicon)[andaniel05](/maintainers/andaniel05)

---

Top Contributors

[![andaniel05](https://avatars.githubusercontent.com/u/21297818?v=4)](https://github.com/andaniel05 "andaniel05 (8 commits)")

---

Tags

annotationsattributesdoctrine-annotationsmetadata-parserparser

### Embed Badge

![Health badge](/badges/thenlabs-meta-parser/health.svg)

```
[![Health](https://phpackages.com/badges/thenlabs-meta-parser/health.svg)](https://phpackages.com/packages/thenlabs-meta-parser)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
