PhpStorm does not recognize Doctrine default entity manager

I have the following code:

$repo = $this->get('doctrine.orm.default_entity_manager')
    ->getRepository('Acme:Foo');

For writing, the code works correctly, since I can use $repoits methods and resulting objects without problems.

However, PhpStorm highlights the line 'doctrine.orm.default_entity_manager'and gives me the following error:

Service missing

I get the same error in my service files when accessing this particular service. After that, obviously, autocomplete doesn't work. Of course, I can use the following workaround:

/** @var \Doctrine\ORM\EntityManager $em */
$em = $this->get('doctrine.orm.default_entity_manager');
$em->getRepository('Acme:Foo');

This way I am still getting a warning, but autocomplete is working correctly. However, I prefer my code to be as clean from as many annotations as possible, plus I'm pretty sure there is an easy solution there. Of course, I cleared my cache several times.

?

EDIT: , Symfony2.

+4
4

PhpStorm "var" ""
"" :
, " " → " "

+3

PHPStorm Symfony, , var/cache/ /dev/shm ( PHPStorm Windows).

var/cache, .

, var/cache/dev/appDevDebugProjectContainer.xml , .

+1

, , :

services.yml :

    entity_manager:
        alias: doctrine.orm.entity_manager

, , , Symfony 2 , .

,

$this->get('entity_manager');

Symfony 2.

" ", Logger, Mailer ..

0

. Settings -> Plugins Symfony . enter image description here

0

Source: https://habr.com/ru/post/1661203/


All Articles