Skip to content

khamer/zap-injector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zap\Injector

A simple dependency injection library

The Zap Injector looks to find the middle ground between the simplicity offered by tiny service locators like Pimple and the real dependency injection libraries like PHP-DI provide.

Usage:

$injector = new \iMarc\Zap\Injector();

// configure your shared dependencies

$injector->addFactory('Request', function() {
	return new Request();
});

$injector->addInstance(Request::createFromGlobals());

$injector->addClass('Session');

// invoke a callable with the dependencies

$returnValue = $injector->invoke(function(Request $req, Session $sess) {
	return array($req, $sess);
});

// call a constructor with dependencies

$instance = $injector->create('some\class');

About

A simple Dependency Injection library for PHP 5.4+

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%