samburns / dirty-needle
Dependency Injection container for PHP
3.0.3
2015-03-15 17:50 UTC
Requires
- php: >= 5.4.0
Requires (Dev)
- behat/behat: 3.0.15
- henrikbjorn/phpspec-code-coverage: ~1.0.1
- phpspec/phpspec: 2.1.1
- phpunit/phpunit: ~4.5
- satooshi/php-coveralls: dev-master
README
dirty-needle
Introduction
Dependency Injection container for PHP
Set up a config file which returns a PHP array, like this:
<?php return array( 'dirty-needle' => array( '@dependency' => array( 'class' => '\Dependency' ), '@class-with-dependency' => array( 'class' => '\ClassWithDependency', 'arguments' => array( '@dependency' ) ), ), );
Then get stuff out of your container, like this:
$diContainer = \DirtyNeedle\DiContainer()::getInstance(); $diContainer->addConfigFile('/path/to/config.php'); $classWithDependency = $diContainer->get('class-with-dependency');
You can also do inject mock objects:
$diContainer->set('service-id', $mockObject);
Reseting definitions and mocks:
$diContainer->reset();
Releases are available supporting PHP5.3-5.6, with the 5.6-compatible releases being significantly faster in their implementation.
Versioning
The project uses semantic versioning.