30 lines
620 B
PHP
30 lines
620 B
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace NoteCat;
|
||
|
|
|
||
|
|
use DI\Container;
|
||
|
|
use Psr\Container\ContainerInterface;
|
||
|
|
|
||
|
|
class Dependencies
|
||
|
|
{
|
||
|
|
public static function createContainer(): Container
|
||
|
|
{
|
||
|
|
$container = new Container();
|
||
|
|
|
||
|
|
// Controllers
|
||
|
|
$container->set(HelloWorldController::class, function (ContainerInterface $c) {
|
||
|
|
return new HelloWorldController(
|
||
|
|
$c->get(HelloWorld::class)
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
// Services
|
||
|
|
$container->set(HelloWorld::class, function () {
|
||
|
|
return new HelloWorld();
|
||
|
|
});
|
||
|
|
|
||
|
|
return $container;
|
||
|
|
}
|
||
|
|
}
|