PHPackages                             debuss-a/awareness - 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. debuss-a/awareness

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

debuss-a/awareness
==================

A set of interfaces and traits to make your classes AWARE, just like JCVD.

1.1.0(3mo ago)0271MITPHPPHP ^8.0

Since Jan 25Pushed 3mo agoCompare

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

READMEChangelog (2)Dependencies (7)Versions (3)Used By (1)

Awareness
=========

[](#awareness)

A set of interfaces and traits to make your classes AWARE, just like JCVD.

What is this?
-------------

[](#what-is-this)

Awareness provides a collection of PSR-compliant "aware" interfaces and traits that allow your classes to declare and receive dependencies through setter injection. Each interface follows the `-aware` pattern, making it easy to implement dependency injection in a standardized way.

Why use Awareness?
------------------

[](#why-use-awareness)

### Perfect for Inflectors

[](#perfect-for-inflectors)

Awareness interfaces are **particularly useful with dependency injection containers that support inflectors**, such as [League Container](https://container.thephpleague.com/). Inflectors allow you to automatically inject dependencies into any class implementing a specific interface, without having to configure each class individually.

**Example with League Container:**

```
use League\Container\Container;
use Psr\Http\Client\ClientInterface;
use Awareness\ClientAwareInterface;

$container = new Container();

// Register your HTTP client
$container->add(ClientInterface::class, GuzzleClient::class);

// Set up an inflector: any class implementing ClientAwareInterface
// will automatically get the HTTP client injected
$container->inflector(ClientAwareInterface::class)
    ->invokeMethod('setClient', [ClientInterface::class]);

// Now any ClientAwareInterface implementation gets the client automatically!
$myService = $container->get(MyApiService::class);
// MyApiService now has the HTTP client injected via setClient()
```

This approach is extremely powerful because:

- ✅ **No per-class configuration needed** - just implement the interface and use the trait
- ✅ **Consistent dependency injection** - same pattern across your entire application
- ✅ **Clean separation of concerns** - dependencies are clearly declared through interfaces
- ✅ **Easy testing** - swap implementations by just using different inflector configurations

### Simple Implementation

[](#simple-implementation)

To make a class "aware" of a dependency:

1. Implement the corresponding aware interface
2. Use the corresponding aware trait (optional, but recommended)

```
use Awareness\CacheAwareInterface;
use Awareness\CacheAwareTrait;

class MyService implements CacheAwareInterface
{
    use CacheAwareTrait;

    public function doSomething()
    {
        // Access the cache through $this->cache
        $this->cache->set('key', 'value');
    }
}
```

Available Interfaces &amp; Traits
---------------------------------

[](#available-interfaces--traits)

Awareness covers all major PSR interfaces:

### PSR-6: Cache

[](#psr-6-cache)

- `CacheItemPoolAwareInterface` / `CacheItemPoolAwareTrait`

### PSR-11: Container

[](#psr-11-container)

- `ContainerAwareInterface` / `ContainerAwareTrait`

### PSR-14: Event Dispatcher

[](#psr-14-event-dispatcher)

- `EventDispatcherAwareInterface` / `EventDispatcherAwareTrait`

### PSR-16: Simple Cache

[](#psr-16-simple-cache)

- `CacheAwareInterface` / `CacheAwareTrait`

### PSR-17: HTTP Factories

[](#psr-17-http-factories)

- `RequestFactoryAwareInterface` / `RequestFactoryAwareTrait`
- `ResponseFactoryAwareInterface` / `ResponseFactoryAwareTrait`
- `ServerRequestFactoryAwareInterface` / `ServerRequestFactoryAwareTrait`
- `StreamFactoryAwareInterface` / `StreamFactoryAwareTrait`
- `UploadedFileFactoryAwareInterface` / `UploadedFileFactoryAwareTrait`
- `UriFactoryAwareInterface` / `UriFactoryAwareTrait`

### PSR-18: HTTP Client

[](#psr-18-http-client)

- `ClientAwareInterface` / `ClientAwareTrait`

And other useful interfaces :

### Mezzio Template Renderer

[](#mezzio-template-renderer)

- `TemplateRendererAwareInterface` / `TemplateRendererAwareTrait`

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

[](#installation)

```
composer require debuss-a/awareness
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance79

Regular maintenance activity

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity40

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

Every ~2 days

Total

2

Last Release

111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1a70117520fe10a630d61c750bbe6888d174e9903825e741470f818ee2c5d1?d=identicon)[debuss-a](/maintainers/debuss-a)

---

Top Contributors

[![debuss](https://avatars.githubusercontent.com/u/2537607?v=4)](https://github.com/debuss "debuss (3 commits)")

### Embed Badge

![Health badge](/badges/debuss-a-awareness/health.svg)

```
[![Health](https://phpackages.com/badges/debuss-a-awareness/health.svg)](https://phpackages.com/packages/debuss-a-awareness)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[windwalker/framework

The next generation PHP framework.

25639.1k1](/packages/windwalker-framework)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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