Skip to content

Commit

Permalink
Provide README
Browse files Browse the repository at this point in the history
  • Loading branch information
e1himself committed Mar 3, 2021
1 parent d758a5e commit b957b5d
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# dependency-resolver
Dependency-resolver utility based on PSR-11 container to be used for auto-wiring
![Status][badge]

# 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.

## 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
<?php

final class MyFancyService
{
public class __construct(callable|LoggerInterface $log)
{
// initialize
}
}

// Resolve service instance, providing dependencies in-place:
$resolver = new DependencyResolver($container);
$service = $resolver->resolve(MyFancyService::class, [
'log' => function (string $priority, string $message) {
error_log("[$priority]: $message");
}]
);

// Resolve service instance, resolving dependencies from container:
$container->set(LoggerInterface::class, $logger);
$resolver = new DependencyResolver($container);
$service = $resolver->resolve(MyFancyService::class);


```

## Credits

- Implemented by [Ivan Voskoboinyk][3]


[1]: https://www.php-fig.org/psr/psr-11/
[2]: https://getcomposer.org/
[3]: https://github.com/e1himself
[badge]: https://github.com/technically-php/array-container/actions/workflows/test.yml/badge.svg

0 comments on commit b957b5d

Please sign in to comment.