https://github.com/zessx/php-di-container
Dependency Injection Container PHP Implementation
https://github.com/zessx/php-di-container
Last synced: about 2 months ago
JSON representation
Dependency Injection Container PHP Implementation
- Host: GitHub
- URL: https://github.com/zessx/php-di-container
- Owner: zessx
- Created: 2020-03-21T18:41:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-21T21:37:29.000Z (over 6 years ago)
- Last Synced: 2025-02-26T14:24:09.630Z (over 1 year ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# PHP DI Container
Dependency Injection Container PHP Implementation.
## Requirements
PHP >= 7.4
## Usage
Explicit binding:
```php
$container = new ZCode\DI\Container();
$container->set(Foo::class, function () {
return new Foo($container->get('bar');)
});
$container->set(Bar::class, function () {
return new Bar();
});
$container->get(Foo::class);
```
Implicit binding relying on constructor injection:
```php
$container = new ZCode\DI\Container();
$container->get(Foo::class);
```
## Testing
```sh
composer run test
```