https://github.com/reliese/php-component-dependency
Dependency Container Abstraction for PHP
https://github.com/reliese/php-component-dependency
Last synced: 4 months ago
JSON representation
Dependency Container Abstraction for PHP
- Host: GitHub
- URL: https://github.com/reliese/php-component-dependency
- Owner: reliese
- Created: 2021-03-11T03:01:36.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-11T03:19:37.000Z (over 4 years ago)
- Last Synced: 2025-02-15T00:48:52.504Z (5 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Reliese Component Dependency
This is the definition of a Dependency Container, also known as Inversion of Control Container, Service Container.
## The Container Interface
It comes with three groups of methods:
### Dependency Registration
- Allows for singleton registration
```php
/**
* @param string $dependency
* @param Closure $abstraction
*
* @return Container
*/
public function singleton(string $dependency, Closure $abstraction) : Container;
```- Allows for a non singleton registration
```php
/**
* @param string $dependency
* @param Closure $abstraction
*
* @return Container
*/
public function register(string $dependency, Closure $abstraction) : Container;
```### Service Location
Each registered dependency can be retrieved with the `resolve` method.
```php
/**
* @param string $dependency
*
* @return mixed
* @throws UnresolvableDependencyException
*/
public function resolve(string $dependency);
```### Method Injection
```php
/**
* @param object $object
* @param string $method
*
* @return mixed
* @throws UnresolvableDependencyException
*/
public function call(object $object, string $method);
```