我在Symfony 4下拥有一个项目,当我尝试对我的项目进行作曲家更新时,出现此错误
Executing script cache:clear
Script cache:clear returned with error code 1[KO]
!!
!! In DefinitionErrorExceptionPass.php line 54:
!!
!! Cannot autowire service "App\Repository\ActeRepository": argument "$registry" of method "__construct()" references interface "Symfony\Br
!! idge\Doctrine\RegistryInterface" but no such service exists. Try changing the type-hint to "Doctrine\Persistence\ManagerRegistry" instea
!! d.
!!
!!
!!
Script @auto-scripts was called via post-install-cmd
[KO]
<?php
以及紧随其后的是ActeRepository
namespace App\Repository;
use App\Entity\Acte;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Acte|null find($id, $lockMode = null, $lockVersion = null)
* @method Acte|null findOneBy(array $criteria, array $orderBy = null)
* @method Acte[] findAll()
* @method Acte[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ActeRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Acte::class);
}
// /**
// * @return Acte[] Returns an array of Acte objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->orderBy('a.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Acte
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
我现在不是问题所在,并且该项目无法更新,我也尝试删除var和vendor文件并清除composer和Symfony的缓存,但是出现相同的问题,我现在不知道为什么我发现了多个提议解决方案,但它们不起作用??
如果不起作用,请尝试在构造函数中更改参数类型:
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
class ActeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Acte::class);
}
...
}