33

Some of my defined classes are not loaded by the IDE when I call Ctrl+B, Go to declaration, Ctrl+click.

I'm using Windows 7, NetBeans, PHP 7.0.1

My classes are defined under <project-root>/foloder00/folder01/folder02/MyClass.php

I call MyClass <project-root>/index.php

Do you know what the problem is? And the workaround?

TRiG
  • 10,148
  • 7
  • 57
  • 107
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

20 Answers20

32

As suggested by Nam, it is cache related. So another approach could be to delete the cache:

  1. Close NetBeans
  2. Delete cache folder (by default, on Linux it is located in /home/USER/.cache/netbeans)
  3. Open the project and wait for the scanning project task to finish.
Dan
  • 2,321
  • 3
  • 27
  • 40
WonderLand
  • 5,494
  • 7
  • 57
  • 76
16

Deleting the Netbeans cache and letting Netbeans rebuild the cache after start fixes the 'go to declaration' issue, as suggested by others.

On Windows 7 with Netbeans 8.0 the path to the cache is

c:\Users{username}\AppData\Local\NetBeans\Cache\

Tilman
  • 1,863
  • 1
  • 12
  • 11
9

I found a workaround for myself. Share with you in case you might need it like me.

Project Property - Include Path - Add the location of the containing folder where it doesn't work/isn't loaded.

Cheers

enter image description here

enter image description here

Nam G VU
  • 33,193
  • 69
  • 233
  • 372
4

For Linux users to delete cache:

rm -fR /home/[user]/.cache/[netbeans_version]

Then restart NetBeans.

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
touzas
  • 89
  • 3
3

Go to Tools->Options-> click on PHP Icon on top -> General tab -> find "Global include path" -> Add Folder ->

if(onLinux) { choose /var/www; } if(onWindows) { choose c:\path_to_htdocs or whatever; }

Ah, too much programming for today.. :)

For me, this repaired autocompletion and ctrl+click on method call.

TomoMiha
  • 1,218
  • 1
  • 14
  • 12
2

I had the same problem with Netbeans 8.0.2.

Clearing the cache had no effect then I noticed the syntax coloring was not working either. The issue was the abbreviated comment tag was not recognized <? and when I changed it to <?php then syntax coloring and Ctrl-B worked again.

2

I resolved this issue deleting the nbproject directory on my project.

After deleteting this directory, just restart your ide. It'll start going to declarations, functions and classes again.

1

If You working with Drupal in NetBeans and have the same ctrl+click (Go to declaration) issue:

  1. Add/associate *.module, *.inc extensions as text/x-php5 files (NetBeans > Options > Miscellaneous > Files).
  2. Close NetBeans.
  3. Clear NetBeans cache (as described above).
  4. Open the project and wait for the scanning project task to finish.
Pavel A.
  • 326
  • 1
  • 3
  • 11
  • Thank you very much, this did the trick. I had been battling "go to declaration" problems since upgrading to Netbeans 8, and was *this close* to moving to another IDE. Oddly enough the autocomplete wasn't affected. My guess is the improved autocomplete for class and interface inheritance added in the 8.x branch gummed up the works somehow, as manually specifying the file types wasn't necessary in 7.x. – mesch Mar 09 '15 at 21:33
1

In windows system, we cannot see the AppData folder directly. So we need to browse the below given path to delete the Netbeans cache: C:\Users{username}\AppData\Local\NetBeans Delete the cache folder. If it still doesn't work then delete the sub-folders inside C:\Users{username}\AppData\Roaming\NetBeans\8.2\var Then reopen your netbeans and let it scan projects.

0

I encountered the same problem on Mac, I solved it by deleting netbeans cache directory:

  • Close netbeans, Find and delete Cache directory of netbeans, it will solve your problem:
  • Replace '7.1.2' with your installed version of Netbeans, in directory paths given below.

MAC:
Remove following directory:

 ~/.netbeans/7.1.2/var/cache/

command:rm -rf ~/.netbeans/7.1.2/var/cache/ enter image description here

Windows XP:
Remove following directory:

C:\Documents and Settings\(user)\.netbeans\7.1.2\var\cache

Windows Vista / 7:
Remove following directory:

C:\Users\(user)\.netbeans\7.1.2\var\cache

Linux:
Remove following directory:

.netbeans/7.1.2/var/cache

LINK:Here is detailed discussion about the issue

Muhammad Nabeel Arif
  • 19,140
  • 8
  • 51
  • 70
0

For me Ctrl + Click does not work when I choose 'Put NetBeans metadata into a separate directory' when doing PHP in Netbeans 7.3.1 on Ubuntu

0

I had the same problem on ubuntu 16.04 and I solved it doing what was written here

  • Edit netbeans.conf (on Ubuntu 16.04 /etc/netbeans.conf)
  • Add the --cp:p /usr/share/java/jcodings.jar to netbeans_default_options
Christophe Ferreboeuf
  • 1,048
  • 14
  • 26
0

I had the same problem and resolved by installing JRE

http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Fawad Ali
  • 564
  • 6
  • 11
0

For me, deleting the Cache didn't work. Deleting and recreating the project did.

For what it's worth, my Cache directory lives here:

C:\Users\{username}\AppData\Local\NetBeans\Cache

I'm using NetBeans 8.1 in Windows 7.

livefree75
  • 720
  • 8
  • 18
0

For me, deleting the Cache folder did not work.

Then i realized that the source files that i have opened in NetBeans, were not included as part of a project. So i went ahead and selected: File > Open Project > chose the original project folder in my htdocs (XAMPP).

Then the declaration mapping worked like a charm. Hope it helps someone out there.

shasi kanth
  • 6,987
  • 24
  • 106
  • 158
0

I got the same issue in Netbeans 11.0. My OS is Ubuntu 18.04. I solved the issue by clearing the cache of netbeans. Cache path of Netbeans 11 is

/home/USER/snap/netbeans/common/cache/11.0

0

Go to Tools->Options-> click on PHP Icon on top -> General tab -> find "Global include path" -> Add Folder -> .

This worked for me on netbeans 11 also

Android
  • 1,420
  • 4
  • 13
  • 23
0

I am with netbeans 8.2. My project was recognized by netbeans as a nodejs project, and my right click->properties looked different: netbeans -> nodejs project properties

I changed it to a php project, and ctrl+click (go to declaration) started to work

boyan
  • 1
  • 2
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 20 '22 at 16:10
-1

OS Linux Centos 7 Netbeans 8.0.2 Problem solved Project Properties / Code Assistance Check property Extra Source Files

-1

For me nothing worked. I was not able to go to some functions of my models whereas some others worked well. I realize that changing the function name was the solution : i had the same function name in other models, and netbeans can't find the good one (well asking would be the best solution). After modification with a unique function name, all is ok