PHPackages                             koriym/attributes - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. koriym/attributes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

koriym/attributes
=================

An annotation/attribute reader

1.0.7(10mo ago)443.6M↓44.5%8[1 issues](https://github.com/koriym/Koriym.Attributes/issues)12MITPHPPHP ^7.2 || ^8.0CI passing

Since Dec 17Pushed 6mo ago4 watchersCompare

[ Source](https://github.com/koriym/Koriym.Attributes)[ Packagist](https://packagist.org/packages/koriym/attributes)[ RSS](/packages/koriym-attributes/feed)WikiDiscussions 1.x Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (14)Used By (12)

Koriym.Attributes
=================

[](#koriymattributes)

[![codecov](https://camo.githubusercontent.com/fb3502ad8b1d141094657e9bf29be976bb904cbde6eb35c5feddb71d37bbadfd/68747470733a2f2f636f6465636f762e696f2f67682f6b6f7269796d2f4b6f7269796d2e417474726962757465732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4f314d42764a726c5036)](https://codecov.io/gh/koriym/Koriym.Attributes)[![Type Coverage](https://camo.githubusercontent.com/4f6a08d7be3a51ccddc51b8a8e2631d1b43ce0c1587c9e741d8ffaf8eed00446/68747470733a2f2f73686570686572642e6465762f6769746875622f6b6f7269796d2f4b6f7269796d2e417474726962757465732f636f7665726167652e737667)](https://shepherd.dev/github/koriym/Koriym.Attributes)[![Continuous Integration](https://github.com/koriym/Koriym.Attributes/workflows/Continuous%20Integration/badge.svg)](https://github.com/koriym/Koriym.Attributes/workflows/Continuous%20Integration/badge.svg)[![Static Analysis](https://github.com/koriym/Koriym.Attributes/workflows/Static%20Analysis/badge.svg)](https://github.com/koriym/Koriym.Attributes/workflows/Static%20Analysis/badge.svg)[![Coding Standards](https://github.com/koriym/Koriym.Attributes/workflows/Coding%20Standards/badge.svg)](https://github.com/koriym/Koriym.Attributes/workflows/Coding%20Standards/badge.svg)

A `koriym/attributes` dual reader implements doctrine/annotation [Reader](https://github.com/doctrine/annotations/blob/master/lib/Doctrine/Common/Annotations/Reader.php) interface in order to read both doctrine/annotation and PHP 8 attributes.

Doctrine annotations are different by design than PHP core one. Not all attributes can be read by this reader (ex. parameters), and not all doctrine/annotations can be read by this reader either. (ex. nested annotations)

However, This reader help you to code forward compatible that supports both PHP 7.x annotations and 8.x attributes in certain senario.

Installation
------------

[](#installation)

```
composer require koriym/attributes

```

Usage
-----

[](#usage)

Create the reader instance.

```
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Koriym\Attributes\DualReader;
use Koriym\Attributes\AttributeReader;

$reader = new DualReader(
    new AnnotationReader(),
    new AttributeReader()
);
assert($reader instanceof Reader);
```

The reader can read both annotations and attributes.

Compatible Annotation
---------------------

[](#compatible-annotation)

Existing doctrine annotations can be changed into annotations that work for both doctrine annotation and PHP8 attributes.

Add `#[Attribute]` attribute.

```
use Attribute;

/** @Annotation */
+#[Attribute]
final class Foo
{
}
```

Then add constructor when annotation has properties. Following example works with both PHP8 attribute and `doctrine/annotations`.

```
use Attribute;
+use Doctrine\Common\Annotations\NamedArgumentConstructor;

/**
 * @Annotation
 * @Target("METHOD")
+* @NamedArgumentConstructor
 */
+#[Attribute(Attribute::TARGET_METHOD)]
final class Foo
{
    public string $bar;
    public int $baz;
+    public function __construct(string $bar = '', int $baz = 0)
+    {
+        $this->bar = $bar;
+        $this->baz = $baz;
+    }
}
```

See more about annotation compatible attribute at [Constructors with Named Parameters](https://github.com/doctrine/annotations/blob/1.11.x/docs/en/custom.rst#optional-constructors-with-named-parameters)

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance61

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 91% 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 ~153 days

Recently: every ~227 days

Total

13

Last Release

184d ago

Major Versions

0.2.1 → 1.0.02021-01-12

1.0.7 → 2.x-dev2025-11-01

PHP version history (3 changes)0.1.0PHP ^7.3 || ^8.0

1.0.4PHP ^7.2 || ^8.0

2.x-devPHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (151 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (8 commits)")[![NaokiTsuchiya](https://avatars.githubusercontent.com/u/17171732?v=4)](https://github.com/NaokiTsuchiya "NaokiTsuchiya (3 commits)")[![lukascellar](https://avatars.githubusercontent.com/u/4516374?v=4)](https://github.com/lukascellar "lukascellar (2 commits)")[![kenjis](https://avatars.githubusercontent.com/u/87955?v=4)](https://github.com/kenjis "kenjis (1 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (1 commits)")

---

Tags

annotatiosattributesphpannotationattribute

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koriym-attributes/health.svg)

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

###  Alternatives

[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k19](/packages/solspace-craft-freeform)[gomachan46/state-machine

simple state machine with annotations for PHP, inspired by AASM known as a Ruby state machine.

1897.8k](/packages/gomachan46-state-machine)[antares/accessible

PHP library that allows you to define your class' getters, setters and constructor with docblock annotations.

123.9k1](/packages/antares-accessible)

PHPackages © 2026

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