Netbeans Auto-compeletion on php class's method

I suspect that the problem is that Netbeans doesn't know the class of your variable. (That happens a lot in PHP, being weakly typed.) Right after you assign the value to the variable, put in a special type hint comment:

$database=someFunction(); /* @var $database DatabaseClass */

This hint will tell Netbeans the type of $database, allowing it to suggest methods. If you have control over the source of someFunction, you can add a hint there, too. See https://blogs.oracle.com/netbeansphp/entry/defining_a_variable_type_in for lots of examples.


Start by adding comments as code-hints where you variables are declared. In class properties use the long form notation for comments:

/**
 * @var \ClassName $varname
 */
 private $varname;

Within classes you can typically use the inline-comments:

/* @var \ClassName $inlinevar */
$inlinevar = new ClassName();

You may need to clear your cache, that will help when autocomplete does not work for classes in the same project. On Linux look under your home directory ~/.cache/.netbeans/ and remove the subdirectory for the project version (always back up first in case something goes wrong).

If your class lives in another project you may need to add the path to the root folder for the other project so Netbeans can scan that folder for class definitions.