| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
| 2025-05-07 (-3 hours ago)  | Not enough user ratings | Total: 84 | All time:  10,053 This week: 206 | |||||
| Version | License | PHP version | Categories | |||
| dependency-resolver 1.0.3 | GNU General Publi... | 5.3 | PHP 5, Language, Design Patterns | 
| Description | Author  | ||||||||||||||||||||||
This class can create class objects and others that it needs.  | 
  | ||||||||||||||||||||||
This project was built for educational purposes, therefore it should NOT run in production environments.
This is a simple Dependency Resolver to resolve classes dependencies and instantiate them automagically.
Install the latest version with:
$ composer require cviniciussdias/dependency-resolver
<?php
use CViniciusSDias\DependencyResolver\Resolver;
// Classes definitions
class Class1
{
    private $class2;
    public function __construct(Class2 $class, Class3 $class3)
    {
        echo $class3->method();
        $this->class2 = $class;
    }
    public function test()
    {
        echo $this->class2;
    }
}
class Class2
{
    public function __construct(Class3 $test, $param = 'default value')
    {
        echo $param . PHP_EOL;
    }
    public function __toString()
    {
        return 'Class2::__toString()';
    }
}
class Class3
{
    public function __construct($paramWithoutDefaulValue)
    {
    }
    public function method()
    {
        return 'Class3::method()' . PHP_EOL;
    }
}
// Resolver usage
$resolver = new Resolver();
$resolver->setParameters(Class3::class, ['paramWithoutDefaulValue' => 'manual value']);
$class1 = $resolver->resolve(Class1::class);
$class1->test();
Vinicius Dias - [email protected] - https://github.com/CViniciusSDias/
This component is licensed under the GPL License
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Doc. | Documentation | |||
| / | src | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.