9

I've just imported a largish php project into NetBeans. Under the top directory I have "app1", "app2", "app3", etc. (each of which are mapped to a domain name), then a "shared" directory for (you guessed it) files used by all the apps.

In app1/route/Search.inc it has:

include_once "../shared/lib/search.inc";

But ctrl-B on this line does nothing. Makes sense, from NetBeans point of view of this as one large application, it should be "../../shared/lib/search.inc". But, for the way the apps are configured, the above is correct, and NetBeans is wrong.

How do I tell NetBeans it needs to go one extra directory up?

Under Include Path, I tried adding "/full/path/to/app1" (so then "../shared/lib/" would be found) (I tried Private tab, then Shared tab, with same results.) But it rejects that, telling me the app1 directory is already part of the application. There is no "Do what I say, and don't think about it, slap!" button.

Adding symbolic links in the file system, just for NetBeans, feels a bit ugly.

I'm wondering if I should make one NetBeans project per app? (I actually tried that first, but as all apps are in the same git repository it gave a lot of noise, so I assumed that was the wrong way.)

ADDITIONAL: I'm most interested in the answer to my last question - is it standard practice to keep each app as a separate NetBeans project, even if they are all in the same git repository?

Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1
Java: 1.7.0_79; OpenJDK 64-Bit Server VM 24.79-b02
Runtime: OpenJDK Runtime Environment 1.7.0_79-b14
(on linux Mint 17)
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
  • A lame workaround is to highlight the base file name, without path (`search.inc`) and launch the "Navigate/Go to File" dialogue (Alt+Shirt+o in my computer). Partial matches also work quite well so you can double click on the file name and get `search` highlighted. – Álvaro González May 20 '15 at 10:35
  • @ÁlvaroG.Vicario Thanks. That fails (it finds nothing), probably for the same reason ctrl-b fails? (But on a similar theme, I did just find that if the filename is also a classname, that ctrl-o to "find type" works.) – Darren Cook May 20 '15 at 11:21
  • "Go to File" doesn't seem to handle paths at all—it only searches in file names so it should find stuff like `search` or `search.inc` or even `earch` (but not `lib/search.inc`) :-? – Álvaro González May 20 '15 at 11:55
  • Sorry, my misunderstanding - I was highlighting the path, not the filename. It does work. – Darren Cook May 20 '15 at 12:15

4 Answers4

4

Make shure that all files of your project are in the project's include path (righ click project -> properties -> include path). Usually there is only the "global include path", which you configure in the NetBeans settings (e.g. to point to your PEAR directory). Add all directories which contain source code you want auto completion for to this include path. Hint: This include path has nothing to do with the include_path used in PHP itself.

Alpesh Rathod
  • 385
  • 3
  • 10
  • Thanks for the reply, Alpesh. As mentioned in my question I have tried this, but it refuses to accept the paths, claiming they are already part of the project. – Darren Cook May 21 '15 at 11:54
4

I'm wondering if I should make one NetBeans project per app? (I actually tried that first, but as all apps are in the same git repository it gave a lot of noise, so I assumed that was the wrong way.)

Yes you should have different NetBeans projects if your apps are separate, and since they are on different domains, it sounds like they are pretty distinct.

One way you can reduce the noise level of this approach is to right click the other app directories and find the option to Mark directory as > excluded and it should disappear (and the files won't be indexed for autocomplete / search / etc).

Scott Jungwirth
  • 6,105
  • 3
  • 38
  • 35
  • Thanks. I just tried to exclude a directory, but cannot see the "Mark directory as" option anywhere. I tried both Files and Project views. ...Ah, under project properties, ignored folders, I could choose Add Folder. Is that what you meant? Adding a test directory there removed it from the Projects view, but not from the Files view... which makes sense. – Darren Cook May 27 '15 at 08:59
2

I have no problems with such a scenario, if I only select the filename. Then NetBeans search for a file with this name in the whole project directory.

If I select the filename and the path, it does not work. Maybe that is your problem?

I have changed nothing else and it works like a charm.

Richard
  • 2,840
  • 3
  • 25
  • 37
  • Thanks for the answer. If I single-click anywhere on the include filename, then ctrl-b, it does nothing. If I double-click just the filename, then ctrl-b, it still does nothing. And I select the filename so the extension is included, then ctrl-b, still nothing. All three approaches work if I manually insert an extra "../" into the include line. – Darren Cook May 20 '15 at 19:19
2

there is a alternative way to set path i.e. via php.ini add the following line in php.ini set path of

include_path = ".:c:\xampp\htdocs\project_name\your_include_folder_name"
restart the apache server
Manoj
  • 118
  • 12