PHPackages                             thomas-squall/php-magic-annotations - 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. thomas-squall/php-magic-annotations

ActiveLibrary

thomas-squall/php-magic-annotations
===================================

Annotations system for PHP

0.9.7(5y ago)33184MITPHPPHP &gt;=5.6.0CI failing

Since Jan 14Pushed 5y ago2 watchersCompare

[ Source](https://github.com/ThomasSquall/PHPMagicAnnotations)[ Packagist](https://packagist.org/packages/thomas-squall/php-magic-annotations)[ RSS](/packages/thomas-squall-php-magic-annotations/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (2)Versions (9)Used By (4)

Annotations for PHP
-------------------

[](#annotations-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/c2a38317eb4e11413e29243c9612ea4e2a894b61f04613a5702f9fba43c2e6bc/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f7068702d6d616769632d616e6e6f746174696f6e732f762f737461626c652e737667)](https://packagist.org/packages/thomas-squall/php-magic-annotations)[![Build Status](https://camo.githubusercontent.com/b743b2297bc0af1e390c793895040f404ae8b9055ab43d069edac42d82c46876/68747470733a2f2f7472617669732d63692e6f72672f54686f6d6173537175616c6c2f5048504d61676963416e6e6f746174696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ThomasSquall/PHPMagicAnnotations)[![Coverage Status](https://camo.githubusercontent.com/ff1ccc43244882a5ac4baba75a36a8acf2521ce096ac95ec61ebcfb4d811cf4f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54686f6d6173537175616c6c2f5048504d61676963416e6e6f746174696f6e732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ThomasSquall/PHPMagicAnnotations?branch=master)[![codecov](https://camo.githubusercontent.com/4ddba8d3254522930d69d4980e0af1d06434ad89c691af8ae39d02ae7a8c6228/68747470733a2f2f636f6465636f762e696f2f67682f54686f6d6173537175616c6c2f5048504d61676963416e6e6f746174696f6e732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/ThomasSquall/PHPMagicAnnotations)[![Total Downloads](https://camo.githubusercontent.com/e8e8ed88ed158680d5b4ed284be521ab94b583fc27a88e0acb467a8c6bde388c/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f7068702d6d616769632d616e6e6f746174696f6e732f646f776e6c6f6164732e737667)](https://packagist.org/thomas-squall/php-magic-annotationsr)[![License](https://camo.githubusercontent.com/42be75c1549e2ac5ecb76a498724c0af91554e3ef6a9c2433fea9a37bf989701/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f7068702d6d616769632d616e6e6f746174696f6e732f6c6963656e73652e737667)](https://packagist.org/packages/thomas-squall/php-magic-annotations)

PHP does not have any kind of native annotation (AKA attributes from .NET world) so if you'd like to implement your own annotation framework think of using this first and save some time.

### Installation

[](#installation)

Using composer is quite simple, just run the following command:

```
$ composer require thomas-squall/php-magic-annotations

```

### Usage

[](#usage)

#### Create a new Annotation

[](#create-a-new-annotation)

First you have to create a new class. In this example the class will be called **MyCustomAnnotation**

```
class MyCustomAnnotation
{

}
```

Then you'll have to extend the **Annotation** class from the library

```
use PHPAnnotations\Annotations\Annotation;

class MyCustomAnnotation extends Annotation
{

}
```

Add some logic to it

```
use PHPAnnotations\Annotations\Annotation;

class MyCustomAnnotation extends Annotation
{
    private $name;
    private $surname;

    public function __constructor($name, $surname)
    {
        $this->name = $name;
        $this->surname = $surname;
    }

    public function GetFullName()
    {
        return "$this->name $this->surname";
    }
}
```

Now our beautiful annotation is ready to go!

#### Use the annotation

[](#use-the-annotation)

Create a class to used to test the annotation

```
class MyTestClass
{

}
```

And add the annotation through the docs

```
/**
 * @MyCustom(name = "Thomas", surname = "Cocchiara")
 **/
class MyTestClass
{

}
```

Now we're ready to test it out!

```
use use PHPAnnotations\Reflection\Reflector;

$myObject = new MyTestClass();
$reflector = new Reflector($myObject);

echo $reflector->getClass()->getAnnotation("MyCustom")->GetFullName();
```

Hope you guys find this library useful.

Please share it and give me a feedback :)

Thomas

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~147 days

Recently: every ~170 days

Total

8

Last Release

2015d ago

PHP version history (2 changes)0.5.1PHP &gt;=5.3.0

0.9.6PHP &gt;=5.6.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7748020?v=4)[Thomas Cocchiara](/maintainers/ThomasSquall)[@ThomasSquall](https://github.com/ThomasSquall)

---

Top Contributors

[![ThomasSquall](https://avatars.githubusercontent.com/u/7748020?v=4)](https://github.com/ThomasSquall "ThomasSquall (46 commits)")

---

Tags

annotationsattributesphpphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thomas-squall-php-magic-annotations/health.svg)

```
[![Health](https://phpackages.com/badges/thomas-squall-php-magic-annotations/health.svg)](https://phpackages.com/packages/thomas-squall-php-magic-annotations)
```

PHPackages © 2026

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