PHPackages                             fratily/attribute-loader - 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. fratily/attribute-loader

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

fratily/attribute-loader
========================

1.0.0(4y ago)04MITPHPPHP ^8.0

Since Jan 31Pushed 4y agoCompare

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

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

Attribute Loader
================

[](#attribute-loader)

Attribute Loader wraps [ReflectionAttribute](https://www.php.net/manual/class.reflectionattribute.php).

How to use
==========

[](#how-to-use)

General
-------

[](#general)

```
#[Attribute]
class FooAttribute {}

#[FooAttribute]
function target_function(): void {}

$loader = new Fratily\AttributeLoader\AttributeLoader(FooAttribute::class);
$attributes = $loader->load(new ReflectionFunction('target_function'));
var_dump($attributes[0]); // object(FooAttribute)
```

Custom instance builder
-----------------------

[](#custom-instance-builder)

`AttributeLoader::load()` uses `ReflectionAttribute::newInstance()` by default to instantiate. However, if you want to interrupt the instantiation process for some reason, you can do the following:

```
#[Attribute]
class FooAttribute {}

#[FooAttribute(name: 'abc')]
function target_function(int $number): void {}

$loader = new Fratily\AttributeLoader\AttributeLoader(
    FooAttribute::class,
    function (ReflectionAttribute $attr) {
        var_dump($attr->getArguments()); // array('name' => 'abc')

        // do something ...
        // ex: trigger event / customize attribute arguments ...

        // MUST return an instance of $attr->getName().
        // MUST not return a subclass of $attr->getName().
        return new FooAttribute();
    }
);
$attributes = $loader->load(new ReflectionFunction('target_function'));
var_dump($attributes[0]); // object(FooAttribute)
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

1568d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c0575d05e23e7ef9b1046a7a922927199c86ef292ebb188758bb214621d7efc?d=identicon)[kento-oka](/maintainers/kento-oka)

---

Top Contributors

[![kento-oka](https://avatars.githubusercontent.com/u/30544668?v=4)](https://github.com/kento-oka "kento-oka (12 commits)")

---

Tags

annotationattributeFratily

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fratily-attribute-loader/health.svg)

```
[![Health](https://phpackages.com/badges/fratily-attribute-loader/health.svg)](https://phpackages.com/packages/fratily-attribute-loader)
```

###  Alternatives

[koriym/attributes

An annotation/attribute reader

433.4M12](/packages/koriym-attributes)[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)[gomachan46/state-machine

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

1893.9k](/packages/gomachan46-state-machine)[marcin-orlowski/lombok-php

Never write boilerplate code for your data class again!

3118.6k1](/packages/marcin-orlowski-lombok-php)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[baibaratsky/yii2-serialized-attributes-behavior

Yii2 Serialized Attributes Behavior

1174.1k9](/packages/baibaratsky-yii2-serialized-attributes-behavior)

PHPackages © 2026

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