Php Symfony未能加载某些依赖项
我在使用symfony依赖项注入的项目中加载Php Symfony未能加载某些依赖项,php,symfony4,Php,Symfony4,我在使用symfony依赖项注入的项目中加载用例时遇到了一些问题 以下代码属于RegisterUserController类 <?php namespace App\Infrastructure\Controller\User; use App\Application\UseCase\User\RegisterUserUseCase; use Symfony\Component\HttpFoundation\Request; /** * Class RegisterUserCont
用例时遇到了一些问题
以下代码属于RegisterUserController
类
<?php
namespace App\Infrastructure\Controller\User;
use App\Application\UseCase\User\RegisterUserUseCase;
use Symfony\Component\HttpFoundation\Request;
/**
* Class RegisterUserController
*
* @package App\Infrastructure\Controller\User
* @author Ismael Moral <jastertdc@gmail.com>
*/
final class RegisterUserController
{
/**
* @var RegisterUserUseCase
*/
protected $registerUserUseCase;
/**
* RegisterUserController constructor.
*
* @param RegisterUserUseCase $registerUserUseCase
*/
public function __construct(
RegisterUserUseCase $registerUserUseCase
) {
$this->registerUserUseCase = $registerUserUseCase;
}
}
这是我在尝试对/user/register/
执行curl请求时遇到的错误
Controller "App\Infrastructure\Controller\User\RegisterUserController" has required constructor arguments and does not exist in the container. Did you forget to define such a service?
如果我用这个修改了控制器的定义,我可以让它工作。所以我必须为控制器定义指定fullnamespace
App\Infrastructure\Controller\User\RegisterUserController:
class: App\Infrastructure\Controller\User\RegisterUserController
arguments: ['@RegisterUserUseCase']
tags: ['controller.service_arguments']
您可以显示RegisterUserController的构造函数吗?@marv255当然可以。所有服务定义是否在services:
键下对齐?要确保不会遗漏一些缩进吗there@Federkun是的,所有服务都在services.yml
文件中定义。我的意思是,services:
键下是PdoWriter
等,还是缺少四个空格?能否显示RegisterUserController的构造函数?@marv255是,当然可以。所有服务定义是否在服务:
键下对齐?要确保不会遗漏一些缩进吗there@Federkun是的,所有服务都在services.yml
文件中定义。我的意思是,PdoWriter
等是否在services:
键下,或者是否缺少四个空格?
App\Infrastructure\Controller\User\RegisterUserController:
class: App\Infrastructure\Controller\User\RegisterUserController
arguments: ['@RegisterUserUseCase']
tags: ['controller.service_arguments']