Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/einenlum/dyc
A very simple DIC, supporting autowiring (NOT production ready)
https://github.com/einenlum/dyc
Last synced: 23 days ago
JSON representation
A very simple DIC, supporting autowiring (NOT production ready)
- Host: GitHub
- URL: https://github.com/einenlum/dyc
- Owner: Einenlum
- License: mit
- Created: 2019-12-16T10:32:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T18:10:17.000Z (3 months ago)
- Last Synced: 2024-12-24T00:15:30.099Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dyc
A very simple DIC, supporting autowiring. For fun only.
## Use
```php
set(\Foo\Bar::class, function(\Dyc\Dic $dic) {
return new \Foo\Bar($dic->get(\Bar\Baz::class));
});$bar = $dic->get(\Foo\Bar::class);
```## Autowiring
We recommend using [haydenpierce/class-finder](https://packagist.org/packages/haydenpierce/class-finder), to get a list of all FQCN in your project.
```php
autowire($classes);$bar = $dic->get(\Foo\Bar::class);
```If one service requires an interface or a scalar, you will need to rewrite the whole definition for this one:
```php
autowire($classes);
$dic->set(\Some\Scalar\Dependent\Service::class, function(\Dyc\Dic $dic) {
return new \Some\Scalar\Dependent\Service($dic->get(\Foo\Bar::class), 'some api key');
});$service = $dic->get(\Some\Scalar\Dependent\Service::class);
```