PHPackages                             codeburner/annotator - 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. codeburner/annotator

ActiveLibrary

codeburner/annotator
====================

Implements a simple, fast and useful annotation support.

v1.0.0(10y ago)323MITPHPPHP &gt;=5.5.0

Since Jan 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/codeburnerframework/annotator)[ Packagist](https://packagist.org/packages/codeburner/annotator)[ RSS](/packages/codeburner-annotator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Codeburner Annotator
====================

[](#codeburner-annotator)

[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/f94e4848d7baa8ac7b1db6f71e235f7f32927e11cde47d919636bfcab8b259ab/68747470733a2f2f7472617669732d63692e6f72672f636f64656275726e65726672616d65776f726b2f616e6e6f7461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/codeburnerframework/annotator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f3e3efdc6745beb547ee54ad88f60e152feeb905bcb8096419c84dceba51d9fb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f64656275726e65726672616d65776f726b2f616e6e6f7461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/codeburnerframework/annotator/?branch=master)

[![SensioLabsInsight](https://camo.githubusercontent.com/396eed6737dd9ac04c1a16aa8a71ff200ecf52ab9bde77ae3a4b9b06037872d3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62643438316333372d613337312d346539312d623261642d3534366335643030323633632f6269672e706e67)](https://insight.sensiolabs.com/projects/bd481c37-a371-4e91-b2ad-546c5d00263c)

A simple and fast annotation support for PHP.

Instalation
-----------

[](#instalation)

Add `codeburner/annotator` to your `composer.json` file.

```
{
    "require": {
        "codeburner/annotator": "1.*"
    }
}
```

or via cli

```
$ composer require codeburner/annotator

```

Don't forget to install or update the composer and include the `vendor/autoload.php` file.

Table of Content
----------------

[](#table-of-content)

- [Introduction](#introduction)
- [Syntax](#syntax)
- [Annotation Classes](#annotation-classes)
- [Filtering Values](#filtering-values)
- [Basic Usage](#basic-usage)
- [Real World Usage](#real-world-usage)

Introduction
------------

[](#introduction)

Annotation is a form of metadata, provide data about a program but is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate. It's frequently used on JAVA applications, in PHP there is no native implementation of annotations, but as example exists the Doctrine ORM that annotate the models using the PHPDoc comment style.

Syntax
------

[](#syntax)

The annotations need to start with `@` and be inside a doc block `/**`. Annotation names receive the same rules of vars in PHP, and they value can be everything BUT it will be parsed as string, the annotator does not make any cast and arrays must be write as jsons.

```
/**
 * @EmptyAnnotation
 * @OneAnnotation 1
 * @ComplexAnnotation {"key1": "value1", "key2": ["value2-1", "value2-2"]}
 */
```

Annotation Classes
------------------

[](#annotation-classes)

By default any annotation is a `Codeburner\Annotator\Annotation` but you can specialize one annotation adding logic to they. For it you must create a new class that extends the `Codeburner\Annotator\Annotation`. The annotation name will be the full class name, but can be affected by the `use` and `namespace` statements.

```
namespace Foo\Bar;

use Foo\FooAnnotation;
use Foo\Bar\BarAnnotation as AliasedAnnotation;

/**
 * @BarAnnotation -f
 * @FooAnnotation -f
 * @AliasedAnnotation -f
 */
```

`BarAnnotation` is `Foo\Bar\BarAnnotation` class, `FooAnnotation` is `Foo\FooAnnotation` class and `AliasedAnnotation` is `Foo\Bar\BarAnnotation class`.

> **NOTE:** All defined annotations must have the `-f` flag in usage, this means that it's a file and can have a filter.

Filtering Values
----------------

[](#filtering-values)

When defining a class for an annotation the arguments could be formmated or filtered by the implementation of method `public function filter()`.

```
class MyAnnotation extends Codeburner\Annotator\Annotation
{
	public function filter()
	{
		array_filter($this->arguments, 'strtoupper');
	}
}
```

Basic Usage
-----------

[](#basic-usage)

```
/**
 * @cook Crystals
 * @with {"local": "trailer", "clothes": ["apron", "briefs"]}
 */

class HeisenbergController
{

	/**
	 * @number 1000
	 */

	public function count()
	{

	}

}

$reflection = new Codeburner\Annotator\Reflection\ReflectionAnnotatedClass(HeisenbergController::class);

echo "I'll cook ",
		$reflection->getMethod("count")->getAnnotation("number"), " ",
		$reflection->getAnnotation("cook"), " in my ",
		$reflection->getAnnotation("with")->getArgument("local"), " with wearing ",
		implode(", ", $reflection->getAnnotation("with")->getArgument("clothes"));
```

Real World Usage
----------------

[](#real-world-usage)

For example registering routes in the [codeburner router system](https://github.com/codeburnerframework/router) only using annotations in a controller.

```
use Codeburner\Router\Annotations\RouteStrategyAnnotation as RouteStrategy;
use Codeburner\Router\Annotations\RoutePrefixAnnotation as RoutePrefix;
use Codeburner\Router\Annotations\RouteAnnotation as Route;

/**
 * @RouteStrategy -f \Codeburner\Router\Strategy\SimpleDispatchStrategy
 * @RoutePrefix -f /blog
 */

class ArticleController
{

	/**
	 * @Route -f /
	 */

	public function index()
	{

	}
}
```

In this code there is three annotations, `@RouteStrategy`, `@RoutePrefix` and `@Route`. The router system will read these annotations and build a route based on then.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3759d ago

### Community

Maintainers

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

---

Tags

annotationcodeburner

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codeburner-annotator/health.svg)

```
[![Health](https://phpackages.com/badges/codeburner-annotator/health.svg)](https://phpackages.com/packages/codeburner-annotator)
```

###  Alternatives

[apy/breadcrumbtrail-bundle

Symfony bundle to generate a dynamic Twig breadcrumbs trail via Annotations, PHP Attributes or PHP methods.

86921.9k](/packages/apy-breadcrumbtrail-bundle)[koriym/attributes

An annotation/attribute reader

433.4M12](/packages/koriym-attributes)[jan-swiecki/simple-annotations

Simple annotation parser

66615.0k18](/packages/jan-swiecki-simple-annotations)[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)[ddesrosiers/silex-annotation-provider

A silex service provider that allows the use of annotations in ServiceControllers.

25246.7k3](/packages/ddesrosiers-silex-annotation-provider)[reinfi/zf-dependency-injection

A Laminas Framework module for loading dependencies via annotation or config entries.

21115.4k1](/packages/reinfi-zf-dependency-injection)

PHPackages © 2026

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