PHPackages                             olvlvl/composer-attribute-collector - 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. olvlvl/composer-attribute-collector

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

olvlvl/composer-attribute-collector
===================================

A convenient and near zero-cost way to retrieve targets of PHP 8 attributes

v2.1.2(2mo ago)184108.8k—6.9%9[2 issues](https://github.com/olvlvl/composer-attribute-collector/issues)7BSD-3-ClausePHPPHP &gt;=8.0CI passing

Since Dec 18Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/olvlvl/composer-attribute-collector)[ Packagist](https://packagist.org/packages/olvlvl/composer-attribute-collector)[ RSS](/packages/olvlvl-composer-attribute-collector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (10)Versions (21)Used By (7)

composer-attribute-collector
============================

[](#composer-attribute-collector)

[![Release](https://camo.githubusercontent.com/8f9a8cd25a87745f29dbc53e2653e3b53d6d26640a821fc43de8cdec0af1f7f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6c766c766c2f636f6d706f7365722d6174747269627574652d636f6c6c6563746f722e737667)](https://packagist.org/packages/olvlvl/composer-attribute-collector)[![Code Coverage](https://camo.githubusercontent.com/51c967f69236ee1865caa9955fd129bf5bba65038dfa235dc93c8f61e38c6d6d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f6c766c766c2f636f6d706f7365722d6174747269627574652d636f6c6c6563746f722f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/r/olvlvl/composer-attribute-collector?branch=main)[![Downloads](https://camo.githubusercontent.com/1096ca85a45e470a36b9721e7eebb559bf7cb20111c15a96cd63344329513513/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6c766c766c2f636f6d706f7365722d6174747269627574652d636f6c6c6563746f722e737667)](https://packagist.org/packages/olvlvl/composer-attribute-collector)

**composer-attribute-collector** is a [Composer](https://getcomposer.org/) plugin designed to effectively *discover* PHP 8 attribute targets, and later retrieve them at near zero cost, without runtime reflection. After the autoloader dump, it collects attributes and generates a static file for fast access. This provides a convenient way to *discover* attribute-backed classes, methods, or properties—ideal for codebase analysis. (For known targets, traditional reflection remains an option.)

#### Features

[](#features)

- Zero configuration
- No reflection in the generated file
- Might improve performance
- No dependency (except Composer of course)
- A single interface to get attribute targets: classes, methods, and properties
- Can cache discoveries to speed up consecutive runs.

Note

Currently, the plugin supports class, method, property, and parameter targets. You're welcome to [contribute](CONTRIBUTING.md) if you're interested in expending its support.

Warning

Attributes used on functions are ignored at this time.

#### Usage

[](#usage)

The following example demonstrates how targets and their attributes can be retrieved:

```
