Skip to content

gephart/dependency-injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gephart Dependecy Injection

php

Dependencies

  • PHP >= 7.4
  • psr/container == 2.0.2

Instalation

composer require gephart/dependency-injection

Using

class A
{
    public function hello(string $world): string
    {
        return "hello " . $world;
    }
}

class B
{
    private $a;

    public function __construct(A $a)
    {
        $this->a = $a;
    }

    public function render()
    {
        return $this->a->hello("world");
    }
}

$container = new \Gephart\DependencyInjection\Container();
$b = $container->get(B::class);
$b->render(); // hello world

About

Gephart DependencyInjection Component

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages