deb0rian
deb0rian

Reputation: 976

Code completion is not working when using symfony container services

I'm using FOSUserBundle in my Symfony 2 application and was wondering how to make a code completion work in PHPStorm, because when you inject the service via container like:

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

And trying to use $userManager to see its interface - I see nothing, because for PHPStorm this is a regular variable, not an object built via "new" operator.

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

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

Thanks!

Upvotes: 3

Views: 874

Answers (2)

Luminita Balas
Luminita Balas

Reputation: 662

For me, executing

composer update

in the console worked.

Upvotes: 0

gp_sflover
gp_sflover

Reputation: 3500

You have to assign to the variable an annotation like showed below to tell to phpstorm from which class the variable receive the instance (ps: I don't use fosUserBundle).

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

PS: Have you installed the Symfony2 plugin?

Upvotes: 5

Related Questions