PHPackages                             saberyjs/annotation - 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. saberyjs/annotation

ActiveLibrary

saberyjs/annotation
===================

this library parse php annotation

1.2.1(8y ago)1301MITPHPPHP &gt;=5.6

Since Mar 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/SABERYJS/php-annotation-helper)[ Packagist](https://packagist.org/packages/saberyjs/annotation)[ RSS](/packages/saberyjs-annotation/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

why need this library
---------------------

[](#why-need-this-library)

if you have used **ReflectionClass** or **ReflectionMethod** of php,you will find that there is a method called **getDocComment**,it means that we can get comment of specified class (and method of class),so,we can do something with it. do you remember Java web Annotation ?? it is a powerful develop tool,but ,this library do not that,it on parse comment,because we never know what you want to do,right ??

how to use
----------

[](#how-to-use)

this library support two function ,as follows:

### get doc comment

[](#get-doc-comment)

firstly we assume there is class called Student:

```
class  Student{
    /**
     * @type post
     * @https true
     * **/
    public function  getName(){
        return '';
    }
}
```

```
$doc=\saberyjs\annotation\Annotation::getAnnotation();
```

Annotation::getAnnotation() return a raw string

### parse comment

[](#parse-comment)

before we get into real code,we must understand that there is a concept called parser,each kind of parser must implement interface called *Parser*, the interface is very simple,i will show you the code:

```
namespace  saberyjs\annotation;

interface  Parser {
    /**
     * @param  $doc string
     * @return  array|null
     * **/
    public function parse($doc);
}
```

every parser must implement *parse* method,it is the only method,this library has two internal parser ,*StandardAnnotationParser* and *PlainAnnotationParser*,of course,you can write your own parser(must implement *Parser* interface) whenever you want . if you use StandardAnnotationParser,code as follows:

```
$doc=\saberyjs\annotation\Annotation::getAnnotation(Student::class);
$parser=new \saberyjs\annotation\StandardAnnotationParser();
$parts=\saberyjs\annotation\Annotation::parseAnnotation($doc,$parser);
```

if you remember the class called *Student*,you will find that it has a method called *getName*,the method has some comment,we paste it here

```
/**
     * @type post
     * @https true
     * **/
```

so after you called *Annotation::parseAnnotation* method with StandardAnnotationParser ,you will get a array,it`s format as follows:

```
$ret=[[
    'name'=>'type',
    'value'=>'post'
    ],[
       'name'=>'https',
       'value'=>'true'
    ]
];
```

you can do whatever you want with $ret,if you are interested in it,you can read the composer package called **thinkphp5-route-helper**

Contact
-------

[](#contact)

I am a php developer in **ShenZhen of China**,if you also like open source ,you can contact me ,My QQ is **1174332406**

last but not least,have a nice day!!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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 ~2 days

Total

3

Last Release

2987d ago

### Community

Maintainers

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

---

Top Contributors

[![SABERYJS](https://avatars.githubusercontent.com/u/12248909?v=4)](https://github.com/SABERYJS "SABERYJS (8 commits)")[![freedevcode](https://avatars.githubusercontent.com/u/201516844?v=4)](https://github.com/freedevcode "freedevcode (1 commits)")

### Embed Badge

![Health badge](/badges/saberyjs-annotation/health.svg)

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

PHPackages © 2026

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