首页 > 解决方案 > 无法加载 Symfony\Bridge\Doctrine\RegistryInterface

问题描述

我想在新计算机上使用我的应用程序,所以我从 Git 中提取所有内容并重新启动composer,并yarn获取我所有的第三方包和库。

运行时composer update出现以下错误:

无法自动装配服务“App\Repository\BlogPostRepository”:方法“__construct()”的参数“$registry”引用接口“Symfony\Bridge\Doctrine\RegistryInterface”,但不存在此类服务。尝试将类型提示更改为“Doctrine\Common\Persistence\ManagerRegistry”。

我的 `BlogRepository 是

namespace App\Repository;

use App\Entity\BlogPost;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;

/**
 * @method BlogPost|null find($id, $lockMode = null, $lockVersion = null)
 * @method BlogPost|null findOneBy(array $criteria, array $orderBy = null)
 * @method BlogPost[]    findAll()
 * @method BlogPost[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class BlogPostRepository extends ServiceEntityRepository
{
    public function __construct(RegistryInterface $registry)
    {
        parent::__construct($registry, BlogPost::class);
    }
}

它是由 symfony 自动生成的,我从未更改过它。这是一个错误还是composer-update改变了一切?

标签: phpsymfonydoctrine-ormcomposer-php

解决方案


它自八月以来已被弃用,如本期所示我的坏

如建议的那样,error我们现在需要使用父接口:

use Doctrine\Common\Persistence\ManagerRegistry;

推荐阅读