Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm does not recognize Doctrine's default entity manager

I have the following code :

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

For the record, the code is working correctly since I can use $repo, its methods and the resulting entities without a problem.

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

Missing service

I get the same error in my services files when referencing that particular service. Following that, obviously, autocomplete does not work. I can use the following workaround, of course:

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

This way I still get a warning but autocompletion works properly. However, I'd rather keep my code clean from this kind of annotation as much as possible, plus I'm almost sure there's an easy fix for that. I have of course cleared my cache multiple times.

How can I fix this?

EDIT: I need to mention I'm using the Symfony2 plugin.

like image 405
SolarBear Avatar asked Nov 18 '16 13:11

SolarBear


1 Answers

In PhpStorm i accidentally mark directory "var" as "Excluded"
So my "fix" was easy:
right click on directory, "Mark Directory as" -> "Cancel Exclusion"

like image 183
Vladimir Miagkov Avatar answered Sep 26 '22 02:09

Vladimir Miagkov