kerasai / container-aware
Tooling inject container into services.
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/kerasai/container-aware
Requires
Requires (Dev)
- consolidation/robo: ~1
- drupal/coder: ^8.3
- kerasai/robo-phpcs: ^0.0.4
This package is auto-updated.
Last update: 2025-10-22 00:12:35 UTC
README
This package adds utilities for making code "container aware".
Usage
To build a service container and automatically inject the container to all container aware services:
<?php use Kerasai\ContainerAware\ContainerAwareCompilerPass; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $containerBuilder = new ContainerBuilder(); $loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__)); $loader->load('services.yml'); $containerBuilder->addCompilerPass(new ContainerAwareCompilerPass()); $containerBuilder->compile();
And on your services, implement the
\Symfony\Component\DependencyInjection\ContainerAwareInterface
interface.
Also use \Symfony\Component\DependencyInjection\ContainerAwareTrait
to easily
implement the interface.