Code completion not working when using Symfony container services

I am using FOSUserBundle in my Symfony 2 application and wondering how to make code completion work in PHPStorm because when you inject this service through a container like:

$userManager = $this->container->get('fos_user.user_manager');

      

And trying to use $ userManager to see its interface - I can't see anything, because for PHPStorm this is a regular variable, not an object created with a "new" operator.

Is there a way to show me the available methods for this object?

As we usually do with real objects: enter image description here

Thank!

+3


source to share


2 answers


You have to assign an annotation to the variable as shown below to tell phpstorm which class the variable gets the instance from (ps: I am not using fosUserBundle).

/** @var \myProject\appBundle\entityManager $userManager */
$userManager = $this->container->get('fos_user.user_manager');

      



PS: Have you installed the Symfony2 plugin ?

+6


source


For me fulfillment

composer update

      



in the console works.

0


source







All Articles