I am upgrading a project from Symfony 3 to Symfony 4
( https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md ) and I have many repositories / services such as:
namespace App\Entity;
use App\Entity\Activation;
use Doctrine\ORM\EntityRepository;
use Predis\Client;
class ActivationRepository extends EntityRepository
{
}
And when I try to run the project in the browser as follows:
http:
I get this error:
(1/1) RuntimeException
Cannot autowire service "App\Entity\ActivationRepository":
argument "$class" of method
"Doctrine\ORM\EntityRepository::__construct()"
references class "Doctrine\ORM\Mapping\ClassMetadata"
but no such service exists.
Does this mean that you need to create a service for "Doctrine \ ORM \ Mapping \ ClassMetadata" in the services.yaml file?
Thanks to auto-preparation, my new services.yaml file is quite small compared to the old one, which had 2000+ lines. The new services.yaml just have a few of them (for now):
App\:
resource: '../src/*'
# Controllers
App\Controller\:
resource: '../src/Controller'
autowire: true
public: true
tags: ['controller.service_arguments']
# Models
App\Model\:
resource: '../src/Model/'
autowire: true
public: true
:
services.yaml ? , , , ?
, Symfony 3 Symfony 4, .
PHP 7.2.0-2 + ubuntu16.04.1 + deb.sury.org + 2 (cli) (: 7 2017 20:14:31) (NTS)
Linux Mint 18, Apache2 Ubuntu.
EDIT/FYI:
"Doctrine\ORM\EntityRepository:: __ construct()", ActivationRepository:
public function __construct(EntityManagerInterface $em, Mapping\ClassMetadata $class)
{
$this->_entityName = $class->name;
$this->_em = $em;
$this->_class = $class;
}
:
/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php