digitalwindow / dependency-injection
Easy-to-use Dependency Injection in PHP
Installs: 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/digitalwindow/dependency-injection
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: 3.7.*
- symfony/class-loader: 2.4.*
This package is not auto-updated.
Last update: 2025-10-07 11:29:00 UTC
README
Dependency injection for PHP
Usage Examples
$injector = new \Awin\DependencyInjection\DependencyInjector;
$injector->configureDependencyParamValue('Foo', 'param1', 'value to use in constructor');
$injector->configureDependencyParamClass('Foo', 'param2', '\Bar');
$foo = $injector->get('Foo')';
Configuration-Free Usage
Simply type-hint the constructor parameters of your dependency, and you needn't offer any configuration information to the injector - it will use reflection to figure out what is needed.
E.g.:
class Foo
{
public function __construct(Bar $param)
{
//...
}
//...
}
$foo = $injector->get('Foo'); // Constructor param retrieved recursively from
// injector at this point, based on type-hint.