"Go to declaration" does not work in Netbeans PHP

23.2k Views Asked by At

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?

20

There are 20 best solutions below

2
On BEST ANSWER

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

0
On

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.

0
On

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

0
On

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

1
On

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
On

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

1
On

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

4
On

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.
0
On

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\

0
On

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
1
On

For Linux users to delete cache:

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

Then restart NetBeans.

3
On

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.

0
On

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

1
On

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.

1
On

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.
0
On

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.

0
On

I had the same problem and resolved by installing JRE

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

0
On

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.

0
On

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
On

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