PHPackages                             bfg/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. bfg/attributes

ActiveBfg-app

bfg/attributes
==============

Designed to work with PHP 8 attributes for classes

1.2.5(2y ago)062.9k↑10.3%16MITPHPPHP &gt;=8.0.0

Since Aug 15Pushed 2y ago3 watchersCompare

[ Source](https://github.com/bfg-s/attributes)[ Packagist](https://packagist.org/packages/bfg/attributes)[ RSS](/packages/bfg-attributes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (14)Used By (6)

Extension attributes
====================

[](#extension-attributes)

Install
-------

[](#install)

```
composer require bfg/attributes
```

Description
-----------

[](#description)

Designed to work with PHP 8 attributes

About the concept
-----------------

[](#about-the-concept)

The concept of this package is to look for attributes in classes and perform them.

Where can I use it?
-------------------

[](#where-can-i-use-it)

When we use the PHP attributes as pointers to some actions.

> It is important not to run this process in the overall stream of the user process, since the execution of this process can threaten the time.

Calling events on attribute
---------------------------

[](#calling-events-on-attribute)

In order to find attributes, we need to specify which attribute we will search, by default the package searches everywhere except folders `public`,`resources`,`storage`, `runtimes`,`database` in the project or you can specify manually in which folder will look for an attribute.

Consider the global attribute search for the method:

```
use Bfg\Attributes\Items\AttributeClassItem;
use Bfg\Attributes\Items\AttributeConstantItem;
use Bfg\Attributes\Items\AttributeMethodItem;
use Bfg\Attributes\Items\AttributePropertyItem;
use Bfg\Attributes\Attributes;

Attributes::new(MyAttribute::class)
    ->map(function (AttributePropertyItem|AttributeMethodItem|AttributeClassItem|AttributeConstantItem $item) {
        // Process with my attribute
    });
```

Or the same search but in a specific folder:

```
use Bfg\Attributes\Items\AttributeClassItem;
use Bfg\Attributes\Attributes;

Attributes::new(MyAttribute::class)
    ->wherePath(app_path())
    ->map(function (AttributePropertyItem|AttributeMethodItem|AttributeClassItem|AttributeConstantItem $item) {
        // Process with my attribute
    });
```

Or find only class attributes

```
Attributes::new(MyAttribute::class)
    ->wherePath(app_path())
    ->whereTargetClass()
    ->map(function (AttributeClassItem $item) {
        // Process with my attribute
    });
```

Or the same search but in a specific class:

```
use Bfg\Attributes\Items\AttributeMethodItem;
use Bfg\Attributes\Attributes;

Attributes::new(MyAttribute::class)
    ->whereClass(MyAnyClassNamespace::class)
    ->whereTargetMethod()
    ->map(function (AttributeMethodItem $item) {
        // Process with my attribute
    });
```

Or you can get all found item attributes:

```
use Bfg\Attributes\Items\AttributePropertyItem;
use Bfg\Attributes\Attributes;

$collectionOfProperties = Attributes::new(MyAttribute::class)
    ->wherePath(app_path())
    ->whereTargetProperty()
    ->all();

$property = Attributes::new(MyAttribute::class)
    ->wherePath(app_path())
    ->whereTargetProperty()
    ->filter(fn (AttributePropertyItem $propertyItem) => $propertyItem)
    ->first();
```

Or you can get all classes:

```
use Bfg\Attributes\Attributes;

Attributes::new()
    ->wherePath(app_path())
    ->classes();

// In all directories
$collectionOfClasses = Attributes::new()->classes();
```

Supported attributes
--------------------

[](#supported-attributes)

The package only supports class attributes, such as: `Class`,`Method`,`Property`,`Class constant`, or they are all at once

Check constants:

1. `\Attribute::TARGET_CLASS`
2. `\Attribute::TARGET_METHOD`
3. `\Attribute::TARGET_PROPERTY`
4. `\Attribute::TARGET_CLASS_CONSTANT`
5. `\Attribute::TARGET_ALL` (by Default)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Every ~69 days

Recently: every ~109 days

Total

13

Last Release

907d ago

Major Versions

0.2.0 → 1.0.02022-09-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/59b2d162a30938ac2c3c56340ebea07a6778a3e1c86cb70b5bc28b69a1c3f04d?d=identicon)[bfg](/maintainers/bfg)

---

Top Contributors

[![Xsaven](https://avatars.githubusercontent.com/u/1726771?v=4)](https://github.com/Xsaven "Xsaven (14 commits)")

---

Tags

laravelattributesextension

### Embed Badge

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

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

###  Alternatives

[laracasts/behat-laravel-extension

Laravel extension for Behat

2611.3M12](/packages/laracasts-behat-laravel-extension)[soulcodex/laravel-behat

Laravel Extension for easy integration with Behat

1760.8k](/packages/soulcodex-laravel-behat)

PHPackages © 2026

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