通过自动装配PHP-DI在另一个类中使用Response Slim 3的实例

时间:2018-09-06 17:31:10

标签: php slim slim-3 php-di

我是自动接线的新手,目前正在使用PHP-DI。

我有以下控制器:

<?php

namespace Registration\Actions;

class Home
{
    protected $responder;
    public function __construct(\Registration\Responders\Home $responder)
    {
        $this->responder = $responder;
    }

    public function __invoke($request,$response)
    {
        return $this->responder->send();

    }
}

这是响应者类

<?php

namespace Registration\Responders;
use Psr\Http\Message\ResponseInterface as Response;

class Home
{
    protected $response;

    public function __construct(Response $response)
    {
        $this->response = $response;
    }

    public function send()
    {
        return 'Test';
    }
}

我遇到以下错误:

Entry "Registration\Actions\Home" cannot be resolved: Entry "Registration\Responders\Home" cannot be resolved: Entry "Psr\Http\Message\ResponseInterface" cannot be resolved: the class is not instantiable Full definition: Object ( class = #NOT INSTANTIABLE# Psr\Http\Message\ResponseInterface scope = singleton lazy = false ) Full definition: Object ( class = Registration\Responders\Home scope = singleton lazy = false __construct( $response = get(Psr\Http\Message\ResponseInterface) ) ) Full definition: Object ( class = Registration\Actions\Home scope = singleton lazy = false __construct( $responder = get(Registration\Responders\Home) ) )

我在做什么错了?

0 个答案:

没有答案
相关问题