Doctrine autocomplete does not work as described



I have checked the doctrine documentation on Jetbrain's website and I have found this page


On paper it looks awesome, but in reality things are sligthly different. When I reach the "Call the methods of a specific entity fetched from the repository" part, it simply does not work, the autocomplete list is empty (except two generic lines) , while my entity has a dozen of methods implemented



And Yes, I know I could add a doc block to specify my variable type, but it would be so much more convenient (and clean) if phpsorm could do it alone, as the jetbrain's documentation says...


Just to confirm, do you have a Symfony plugin installed and enabled already?


I have the same issue. Symfony support, PHP Annotation plugins installed.


Vasiliy Yur Yes I have symfony plugin installed and enabled. Here's my config:



Would it be possible to share a small reproducible project, so I could check how it works on my side?


This feature currently doesn't work. It seems like it worked before the latest update.  PhpStorm totally fails at this now. For some stupid reason PHPStorm only sees the first 4 methods listed in the comment at the top of the repository the bs findBy etc.
To actually be able to see your custom methods in your repository you must resort to this tomfoolery

* @var UserPrivilegesRepository $repository
$repository = $entityManager->getRepository(UserPrivileges::class);

Sorry the 404 link doesn't help. It seems to me that this feature worked at one time, then it quit working. The only solution I have found is the one I posted. PhpStorm seems a bit wonky


Ok, sorry. Quote from there:

It appears that your vendor directory is broken, so PhpStorm is right when it shows you the warnings about missing classes - those classes are not presented in the project.
What I think you need to do is:

  1. Log into the server via SSH
  2. Change the directory to the project root
  3. Delete the vendor directory
  4. Run composer install (make sure you are doing that remotely, not locally)
  5. Wait until dependencies are installed
  6. In PhpStorm, invoke Deployment | Download from ... in the context menu on the project root.

Can you try it?


For some reason this was it.
The vendor directory was there and working for my project. However ,PHPStorm decided it didn't like something about it so it pretends it is missing. When I started the IDE it was telling me the vendor folder was missing. I looked and I was like, nope there it is right there. I had to delete it and run composer install. Then I restarted PHPStorm, got some other error, the dialog had this button to send the errors but it was greyed out and wouldn't work.

But reinstalling with composer fixes it for some reason. Weird I was programming for days like this wondering WTF it didn't know about my classes anymore. I did a bunch of updates to my Symfony project maybe it did something Phpstorm didn't like.



Do I understand correctly that you managed to fix the error?


Yes deleting the vendor folder then running composer install got the doctrine repository code hints working again. I was surprised it only affected PHPStorm though and not the actual project. And what is even more odd is the solution I posted above makes it work too. Thanks.


Please sign in to leave a comment.