apinephp / resolver
A IoC Dependency Resolver
2.0.0
2019-12-12 21:12 UTC
Requires
- php: >=7.4
- psr/container: ^1.0
- vimeo/psalm: ^3.7
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-11-21 03:42:08 UTC
README
A IoC Dependency Resolver
Resolve dependencies of functions, methods, and constructors from a DI container
Installation
Installation is made with composer
composer require apinephp/resolver
The package requires PHP 7.4 or newer.
Usage Example
<?php
use Apine\Resolver\CallableResolver;
use Apine\Resolver\ObjectConstructorResolver;
use Apine\Resolver\ObjectMethodResolver;
// Create an instance of a class
$resolver = new ObjectConstructorResolver($container);
$object = $resolver->resolve(StubClass::class);
// Execute a method
$resolver = new ObjectMethodResolver($container, $object);
$result = $resolver->resolve('method');
// Call a function
$resolver = new CallableResolver($container);
$result = $resolver->resolve('functionName');