NoteCat/src/Dependencies.php

30 lines
620 B
PHP
Raw Normal View History

2020-06-28 19:26:59 +02:00
<?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;
}
}