2

I'm having some difficulty with PhpStorm picking up my namespaces and use statements in a Symfony 2.8 project. In the past it's been OK, mainly when working locally, but this time I'm working on a development server rather than my local machine.

In this example, my User entity is extending the FOSUserBundle class and I am including this and Doctrine like so:

namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

Although the top most use statement has a green mark underneath (Undefined Namespace) and, subsequently, it states that the User class is undefined too. The FOSUserBundle was installed via command line, in the usual way with composer require.

This causes me some problems as normally it would be easy to jump to the abstract class and / or included classes within PhpStorm but it's like it's no longer recognising them.

I've tried to Invalidate Cache / Restart as someone else suggested on here but the problem remains.

If anyone has any ideas as to why this may be happening, I would be grateful to hear them.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Michael Emerson
  • 1,774
  • 4
  • 31
  • 71
  • 1
    Did you mark your vendors as source files ? – Florent Destremau Aug 23 '16 at 08:55
  • Not sure what this means. I'm working remotely, not locally. – Michael Emerson Aug 23 '16 at 09:13
  • In your project settings, you can make the vendor directory as a source root - that'll tell PHPStorm to use it as a namespace root, and as such you'll get the classes in there as autocomplete suggestions. Or you can right click the vendor directory and select "Mark directory as -> sources root" – YamiTenshi Aug 23 '16 at 09:29
  • It seems I can only do this for local files, so I just downloaded all the server files and I guess I'll work from local and upload when I edit them. I don't think it's possible to set up source roots on the remote host - I don't get that option when I right click anyway. – Michael Emerson Aug 23 '16 at 09:58
  • 1
    You have to have all your code locally (well, at least the most important parts of it) -- IDE cannot index your code that is available on Remote host only. http://stackoverflow.com/a/36850634/783119 – LazyOne Aug 23 '16 at 10:56

0 Answers0