PHPackages                             cakephp/attribute-resolver - 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. [Framework](/categories/framework)
4. /
5. cakephp/attribute-resolver

ActiveLibrary[Framework](/categories/framework)

cakephp/attribute-resolver
==========================

PHP Attribute discovery and resolution library for CakePHP applications

6.x-dev(1mo ago)10MITPHPPHP &gt;=8.4

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/cakephp/attribute-resolver)[ Packagist](https://packagist.org/packages/cakephp/attribute-resolver)[ Docs](https://cakephp.org)[ RSS](/packages/cakephp-attribute-resolver/feed)WikiDiscussions 6.x Synced 1mo ago

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

CakePHP Attribute Resolver
==========================

[](#cakephp-attribute-resolver)

The Attribute Resolver provides efficient discovery and querying of PHP 8 attributes across your codebase. It enables runtime attribute discovery for features like auto-discovery of routes, commands, and other framework components.

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

[](#installation)

```
composer require cakephp/attribute-resolver
```

Configuration
-------------

[](#configuration)

Configure the resolver with paths to scan and optional caching. Paths support glob/wildcard patterns and are automatically expanded against both the application root and all loaded plugin paths:

```
// In config/bootstrap.php or Application::bootstrap()
use AttributeResolver\AttributeResolver;

AttributeResolver::setConfig('default', [
    'paths' => [
        'src/**/*.php', // Scans app src/ and all plugin src/ directories
    ],
    'excludePaths' => ['vendor', 'tmp'],
    'cache' => '_cake_attributes_', // Cache configuration name (default)
    'validateFiles' => true, // Check if source files changed
    'basePath' => ROOT, // Optional: defaults to ROOT
]);

// Optional: Configure multiple collections
AttributeResolver::setConfig('routes', [
    'paths' => ['src/Controller/**/*.php'], // Scans Controllers in app and plugins
    'cache' => '_cake_attributes_',
    'excludeAttributes' => [SomeAttribute::class],
]);

// Disable caching (not recommended for production)
AttributeResolver::setConfig('nocache', [
    'paths' => ['src/**/*.php'],
    'cache' => false,
]);
```

### Cache Configuration

[](#cache-configuration)

For maximum performance, configure the cache to use the File adapter which enables PhpEngine:

```
// In config/app.php
use Cake\Cache\Cache;

Cache::setConfig('_cake_attributes_', [
    'className' => 'File', // Required for PhpEngine
    'path' => CACHE,
    'duration' => '+1 year',
]);
```

Usage
-----

[](#usage)

```
use AttributeResolver\AttributeResolver;

// Get all attributes from default configuration
$collection = AttributeResolver::collection();

// Filter by specific attribute class (uses magic method forwarding)
$routes = AttributeResolver::withAttribute(Route::class);

// Chain multiple filters
$adminRoutes = AttributeResolver::withAttribute(Route::class)
    ->withNamespace('App\Controller\Admin');

// Filter by target type
$classAttributes = AttributeResolver::withAttribute(MyAttribute::class)
    ->withTargetType(AttributeTargetType::CLASS_TYPE);

// Filter by plugin
$pluginCommands = AttributeResolver::withAttribute(ConsoleCommand::class)
    ->withPlugin('MyPlugin');

// Use named configurations
$commands = AttributeResolver::collection('commands')
    ->withAttribute(ConsoleCommand::class);

// Clear cache
AttributeResolver::clear('default');
```

CLI Commands
------------

[](#cli-commands)

### Cache Warming

[](#cache-warming)

```
# Warm up the attribute cache
bin/cake attributes warm

# Output:
# Warming attribute cache...
# Cached 28 attributes in 0.15s

# Use a specific configuration
bin/cake attributes warm --config custom
```

### List Attributes

[](#list-attributes)

```
# List all discovered attributes
bin/cake attributes list

# Filter by attribute type, class, or namespace
bin/cake attributes list --type method --class UsersController

# Show full class names without truncation
bin/cake attributes list --verbose
```

### Inspect Details

[](#inspect-details)

```
# Inspect specific attributes with full metadata
bin/cake attributes inspect Route

# Output:
# Found 3 attribute(s):
#
# 1. Route
#    Attribute Class: App\Attribute\Route
#    Target Class: App\Controller\UsersController
#    Plugin: -
#    Target: index (method)
#    File: src/Controller/UsersController.php:42
#    Arguments:
#      - path: /users/index
#      - methods: ["GET"]

# Inspect all attributes on a class
bin/cake attributes inspect --class ArticlesController
```

Documentation
-------------

[](#documentation)

Please make sure you check the [official documentation](https://book.cakephp.org/6/en/core-libraries/attributes.html)

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance96

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 57.1% 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

55d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23666?v=4)[CakePHP](/maintainers/cakephp)[@cakephp](https://github.com/cakephp)

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (4 commits)")[![josbeir](https://avatars.githubusercontent.com/u/26058?v=4)](https://github.com/josbeir "josbeir (2 commits)")[![phpnut](https://avatars.githubusercontent.com/u/148097?v=4)](https://github.com/phpnut "phpnut (1 commits)")

---

Tags

reflectioncakephpmetadataattributesphp8

### Embed Badge

![Health badge](/badges/cakephp-attribute-resolver/health.svg)

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

###  Alternatives

[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)[cakephp/utility

CakePHP Utility classes such as Inflector, String, Hash, and Security

12027.1M63](/packages/cakephp-utility)[cakephp/database

Flexible and powerful Database abstraction library with a familiar PDO-like API

9724.6M33](/packages/cakephp-database)[cakephp/migrations

Database Migration plugin for CakePHP

13912.0M220](/packages/cakephp-migrations)[cakephp/bake

Bake plugin for CakePHP

11211.2M156](/packages/cakephp-bake)[cakephp/datasource

Provides connection managing and traits for Entities and Queries that can be reused for different datastores

4624.6M11](/packages/cakephp-datasource)

PHPackages © 2026

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