gephart / dependency-injection
Gephart DependencyInjection Component
0.5
2017-10-08 19:30 UTC
Requires
- php: >=7.1
- psr/container: 1.0.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-04-14 00:12:34 UTC
README
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