Skip to content

systream/dependency-injection-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repository

For saving models with repository pattern.

Installation

You can install this package via packagist.org with composer.

composer require systream/dependency-injection-container

composer.json:

"require": {
    "systream/dependency-injection-container": "1.*"
}

This library requires php 5.6 or higher, but also works on php 5.4.

Usage

$di = new DependencyInjectionContainer();
$di->bind(FixtureTestInterface::class, function () {
	return new ObjectA();
});

$di->has(FixtureTestInterface::class); // will return true

$instance = $di->get(FixtureTestInterface::class); // will return ObjectA instance 

Create

class TestObjectB {
	public function __construct(FixtureTestInterface $test) {
	}
}

$di = new DependencyInjectionContainer();
$di->bind(FixtureTestInterface::class, function () {
	return new ObjectA();
});

$testObject = $di->create(TestObjectB::class); 

Test

Build Status

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages