Code Completion on custom php classes

I'm currently testing out PHPStorm as an alternative to another IDE and was hoping someone has run into this problem and knows how to fix it.

Platform: Windows 7 x64
Product: PHPStorm 2.0
Build: PS-98.458

Issue: Unable to get code completion to work for custom classes.

Project is a fairly large one, with many classes all within the project. While looking at existing code an object created from a class such as:

$obj = new MyClass('params here');
or like
$obj = new \mynamespace\subclass\MyClass('any params here');

There exists no code completion for methods within these classes, ie:

$obj->//no completion even with ctrl + space

The only thing that has been done, is download/install the IDE, create the project from existing files, setup SVN and SFTP accounts. Please advise how this can be resolved.


Comment actions Permalink

Are you sure you added all directories with classes to your project? Also, you will not have autocompletion if you have 2 classes with the same name in the project (as I know).

Comment actions Permalink

Thanks for the response.

I checked under Settings [Project Settings] -> Directories and it lists the current project root.

All folders with code files are listed below this and show in the file browser to the right, none of which show as "Excluded". Do I need to individually add any folders within the project root, I would have thought they would be included as they are within the main project folder?

Comment actions Permalink

Hi Brandon,

If all classes are somewhere within your project folder then you do not need to add any additional subfolders in Settings | Directories.

Most likely PhpStorm cannot resolve class name/path properly. As Dmitriy already mentioned, you may have more than one class with the same name in your project (that is the most common reason for such behaviour). Can you please double check this moment.

Please note that namespace support is a work in progress and in some scenarios is still does not work properly. You can see all recorded tickets in this regard here:

Comment actions Permalink

I can confirm this project does not use any duplicate class names (or file names for that matter). It does use namespaces fairly heavily to leverage the new functionality in php 5.3. I will do some more tests with different classes and namespaces to see if I can better articulate the circumstances causing this.


Please sign in to leave a comment.