https://github.com/technically-php/dependency-resolver
🔁 Dependency-resolver utility based on PSR-11 container to be used for auto-wiring. :elephant: PHP8-ready :tada:
https://github.com/technically-php/dependency-resolver
dependency dependency-resolver injection php8 psr-11
Last synced: 9 months ago
JSON representation
🔁 Dependency-resolver utility based on PSR-11 container to be used for auto-wiring. :elephant: PHP8-ready :tada:
- Host: GitHub
- URL: https://github.com/technically-php/dependency-resolver
- Owner: technically-php
- License: mit
- Created: 2021-03-03T12:42:18.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-27T21:39:39.000Z (over 2 years ago)
- Last Synced: 2024-04-22T21:08:18.096Z (over 1 year ago)
- Topics: dependency, dependency-resolver, injection, php8, psr-11
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Technically Dependency Resolver
`Technically\DependencyResolver` is a simple yet powerful tool to instantiate classes
autowiring their dependencies by resolving them from a [PSR-11][1] container
or recursively instantiating them with *DependencyResolver* itself.
![Status][badge]
## Features
- Based on PSR-11
- PHP 8.0 ready (supports union type hints; see examples below)
- PHP 7.1+ compatible
- Recursive dependencies autowiring
- Semver
- Tests
## Installation
Use [Composer][2] package manager to add *Technically\DependencyResolver* to your project:
```
composer require technically/dependency-resolver
```
## Example
```php
construct(MyFancyService::class, [
'log' => function (string $priority, string $message) {
error_log("[$priority]: $message");
}]
);
// Resolve service instance from container, falling back to `construct()` otherwise.
$resolver = new DependencyResolver($container);
$service = $resolver->resolve(MyFancyService::class);
```
## Changelog
All notable changes to this project will be documented in the [CHANGELOG](./CHANGELOG.md) file.
## Credits
- Implemented by :space_invader: [Ivan Voskoboinyk][3]
- Heavily inspired by Dawid Kraczkowski's work in [igniphp/container][4]
[1]: https://www.php-fig.org/psr/psr-11/
[2]: https://getcomposer.org/
[3]: https://github.com/e1himself?utm_source=web&utm_medium=github&utm_campaign=technically/dependency-resolver
[4]: https://github.com/igniphp/container
[badge]: https://github.com/technically-php/dependency-resolver/actions/workflows/test.yml/badge.svg