Skip to content

ds82/pumice

Repository files navigation

Pumice

Build Status

A dependency injection container for PHP with annoation support. Pumice is heavly inspired by Google's Gucie for Java. If you have already worked with Guice, you'll feel familiar with Pumice's syntax.

This project is in early stage of its development, use it with care!

Quick Example

namespace foo;

class A {

	public $value;
	/**
	 * @DefaultValue("value")
	 */
	public function __construct($value = null) {
		$this->value = $value;
	}
}
namespace foo;

use foo\A;

class B {
	
	public $a;

	public function __construct(A $a) {
		$this->a = $a;
	}
}
class MyModule extends Module {
	
	public function configure() {
		$this->bind('some\X')->to('foo\B')->in(Scope::SINGLETON);
		$this->bindAnnotation('DefaultValue')->toValue(1000);
	}
}
$injector = Pumice::createInjector(new MyModule());
$b = $injector->getInstance('some\X');

$this->assertEquals(1000, $b->a->value);

For more examples look at the phpunit-tests.

About

A dependency injection container for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages