Download the PHP package debuss-a/awareness without Composer
On this page you can find all versions of the php package debuss-a/awareness. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download debuss-a/awareness
More information about debuss-a/awareness
Files in debuss-a/awareness
Package awareness
Short Description A set of interfaces and traits to make your classes AWARE, just like JCVD.
License MIT
Informations about the package awareness
Awareness
A set of interfaces and traits to make your classes AWARE, just like JCVD.
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?
Perfect for Inflectors
Awareness interfaces are particularly useful with dependency injection containers that support inflectors, such as League Container. 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:
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
To make a class "aware" of a dependency:
- Implement the corresponding aware interface
- Use the corresponding aware trait (optional, but recommended)
Available Interfaces & Traits
Awareness covers all major PSR interfaces:
PSR-6: Cache
CacheItemPoolAwareInterface/CacheItemPoolAwareTrait
PSR-11: Container
ContainerAwareInterface/ContainerAwareTrait
PSR-14: Event Dispatcher
EventDispatcherAwareInterface/EventDispatcherAwareTrait
PSR-16: Simple Cache
CacheAwareInterface/CacheAwareTrait
PSR-17: HTTP Factories
RequestFactoryAwareInterface/RequestFactoryAwareTraitResponseFactoryAwareInterface/ResponseFactoryAwareTraitServerRequestFactoryAwareInterface/ServerRequestFactoryAwareTraitStreamFactoryAwareInterface/StreamFactoryAwareTraitUploadedFileFactoryAwareInterface/UploadedFileFactoryAwareTraitUriFactoryAwareInterface/UriFactoryAwareTrait
PSR-18: HTTP Client
ClientAwareInterface/ClientAwareTrait
And other useful interfaces :
Installation
Requirements
- PHP 8.0 or higher
All versions of awareness with dependencies
psr/container Version ^2.0
psr/http-factory Version ^1.1
psr/cache Version ^3.0
psr/simple-cache Version ^3.0
psr/http-client Version ^1.0
psr/event-dispatcher Version ^1.0
psr/link Version ^2.0