- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么在尝试获取 ContainerInterface
时出现此错误:
ERROR - exception 'ErrorException' with message 'Catchable Fatal Error: Argument 5 passed to Project\InvitationsBundle\Invitations::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in /www/project/app/cache/dev/appDevDebugProjectContainer.php on line 1709 and defined in /www/project/src/Project/InvitationsBundle/Invitations.php line 23'
在构造方法中添加ContainerInterface
时出现错误:
<?php
namespace Pro\InvitationsBundle;
use Pro\CommunityBundle\Entity\Community;
use Pro\InvitationsBundle\Entity\Invitation;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Pro\UserBundle\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Invitations
{
private $mailer;
private $translator;
private $templating;
private $doctrine;
private $container;
function __construct(\Swift_Mailer $mailer, TranslatorInterface $translator, EngineInterface $templating,
Registry $doctrine, ContainerInterface $container)
{
$this->mailer = $mailer;
$this->translator = $translator;
$this->templating = $templating;
$this->doctrine = $doctrine;
$this->container = $container;
}
...
}
最佳答案
可能您的服务定义有误。您应该注入(inject)所有 Invitations
参数,例如:
invitations:
class: Redconvive\InvitationsBundle\Invitations
arguments: [@mailer, @translator, @templating, @doctrine, @service_container]
您可能忘记了 @service_container
。
顺便说一句。请注意,注入(inject)整个容器是个坏主意。您应该只注入(inject)必要的服务。
关于php - 将 ContainerInterface 作为参数传递时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21850043/
为什么在尝试获取 ContainerInterface 时出现此错误: ERROR - exception 'ErrorException' with message 'Catchable Fatal
为什么在尝试获取 ContainerInterface 时出现此错误: ERROR - exception 'ErrorException' with message 'Catchable Fatal
为什么我有这个错误? Catchable Fatal Error: Argument 1 passed to Application\Sonata\ProductBundle\Controller\P
我正在尝试在 Slim 中使用 Controller ,但一直出现错误 PHP 可捕获 fatal error :参数 1 传递给 TopPageController::__construct() 必
我在我的 Models 上遇到了 Slim 3 的 Catchable fatal error,我在我的 Controllers 上进行了类似的设置,并且工作正常。当我在我的 Modal class
安装了新的 Laravel 8 项目并在加载第一个实例时,出现以下错误。这很奇怪,因为我把它放在一边,后来从 Laravel 5.8 -> 6 升级了另一个项目(工作正常),当我去检查网站时遇到了类似
我是一名优秀的程序员,十分优秀!