所以,我第一次尝试设置 php-di,但我在构建器方面遇到了一些问题。我不断收到错误:
Uncaught exception 'DI\NotFoundException' with message 'No entry or class found for 'IConnection'' in /path/PHPDiContainer.php'
我的容器设置哪里出错了?
<?php
require_once 'vendor/autoload.php';
use repositories\Connection;
use irepositories\IConnection;
use DI\ContainerBuilder;
$container = DI\ContainerBuilder::buildDevContainer();
$builder = new DI\containerBuilder();
$builder->addDefinitions([
IConnection::class => DI\object(Connection::class)
]);
$container = $builder->build();
$connection = $container->get('Connection');
... Code to show it works.
?>