将Symfony从3.4升级到4.4(无flex)获得服务或别名后已被删除或嵌入容器时,
在将Symfony从3.4更新为4.4(无flex)后,我遇到了此错误“ Tactician.CommandBus”服务或别名已被删除或在集装箱被编译时已删除或嵌入。您应该将其公开,或者停止直接使用容器并使用依赖注入。
di-Extra-Bundle向控制器注入代表
class MngmtController extends AbstractFOSRestController
{
/**
* @var CommandBus
*/
private $commandBus;
/**
* @var CommandBus
*/
private $mngmtCommandBus;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var MngmtService
*/
private $mngmtService;
/**
* @param ContainerInterface $container
* @param CommandBus $commandBus
* @param CommandBus $mngmtCommandBus
* @param LoggerInterface $logger
* @param MngmtService $mngmtService
*
* @DI\InjectParams({
* "container" = @DI\Inject("service_container"),
* "commandBus" = @DI\Inject("tactician.commandbus"),
* "mngmtCommandBus" = @DI\Inject("tactician.commandbus.mngmt"),
* "logger" = @DI\Inject("monolog.logger"),
* "mngmtService" = @DI\Inject("app.services.mngmt_service"),
* })
*/
public function __construct(
ContainerInterface $container,
CommandBus $commandBus,
CommandBus $mngmtCommandBus,
LoggerInterface $logger
MngmtService $mngmtService,
) {
$this->container = $container;
$this->commandBus = $commandBus;
$this->mngmtCommandBus = $mngmtCommandBus;
$this->logger = $logger;
$this->mngmtService = $mngmtService;
}
。
_defaults:
public: true
League\Tactician\CommandBus:
alias: 'tactician.commandbus'
public: true
Psr\Log\LoggerInterface:
alias: 'monolog.logger'
public: true
我正在使用JMS / 错误
After updating symfony from 3.4 to 4.4(without flex) i am getting this error The "tactician.commandbus" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
I am injecting depnedeicies to controller using jms/di-extra-bundle
class MngmtController extends AbstractFOSRestController
{
/**
* @var CommandBus
*/
private $commandBus;
/**
* @var CommandBus
*/
private $mngmtCommandBus;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var MngmtService
*/
private $mngmtService;
/**
* @param ContainerInterface $container
* @param CommandBus $commandBus
* @param CommandBus $mngmtCommandBus
* @param LoggerInterface $logger
* @param MngmtService $mngmtService
*
* @DI\InjectParams({
* "container" = @DI\Inject("service_container"),
* "commandBus" = @DI\Inject("tactician.commandbus"),
* "mngmtCommandBus" = @DI\Inject("tactician.commandbus.mngmt"),
* "logger" = @DI\Inject("monolog.logger"),
* "mngmtService" = @DI\Inject("app.services.mngmt_service"),
* })
*/
public function __construct(
ContainerInterface $container,
CommandBus $commandBus,
CommandBus $mngmtCommandBus,
LoggerInterface $logger
MngmtService $mngmtService,
) {
$this->container = $container;
$this->commandBus = $commandBus;
$this->mngmtCommandBus = $mngmtCommandBus;
$this->logger = $logger;
$this->mngmtService = $mngmtService;
}
I have tried adding this in services.yml, but didn't help
_defaults:
public: true
League\Tactician\CommandBus:
alias: 'tactician.commandbus'
public: true
Psr\Log\LoggerInterface:
alias: 'monolog.logger'
public: true
I am following older directory structure not updated to sf4/flex directory structure, Please help me with the above error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论