Netbeans does not find all my include_once paths - php

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)

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.

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).

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.

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

Related

Symbolic Links in Windows with PHP project using Netbeans 7

I'm working on a PHP project and using Netbeans 7.0.1 and the last PHPUnit.
The project has two folders each one with its own bootstrap.
Let's say folders are project1 and Common, then project1 uses a SymbLink to access Common and in Mac world that works, but now I'm working on windows and from project1 unit tests, Common files are not found.
I tried to add Common folder as Global Path in Project1, but it still doesn't find Common files.
Is there any place where I can configure Netbeans to work?
Thanks in advance. Guillermo.
It's been a while since I've used this tool, and it might depend upon which version of Windows you're running, but you might also look into a tool called Junction Link Magic. It does symlinks on Windows, or some version thereof.
That being said, relying on symbolic links in the manner you're describing seems non-portable at best. My stronger recommendation would be to fix your build script (ant/maven/whatever) so that it works everywhere without relying on symlinks in the first place.
Your best bet is to add the Common folder to your include path. Otherwise, you can always just copy and paste the actual folder (not recommended).

Eclipse PDT, how to setup 'Run Configurations'?

Eclipse PDT is very slick, but here's my issue, Re: Launcher (run configurations)
I'm trying to keep things very clean, concise on my local machine (with WAMP stack) and I have a number of virtual hosts configured, that keep my URL's easy to use.
In eclipse, I set up PHP servers to correspond with these Vhosts.
Since I have existing code, I'm usually setting up a new project 'from existing sources'.
Then when I try to 'run', I get URL auto-generated like this; with the Project name in it:
http://MyVhost/MyProj/testing.php
And what I really want is:
http://MyVhost/testing.php
I find myself doing a lot of editing and adjusting of the servers and run configurations, before I can get the URL that works. Any recommendations ?
You can create a new Run Configuration Run->Run Configurations and as long as you have setup your virtual hots as servers, you can untick 'Auto Generate' option under URL and enter you URL manually for each project. So even if you point to different files in your project, it won't matter because Eclipse will use your manually entered URL. Save these and then you're done!
The path part of the autogenerated URL is the Base Path (which defaults to / + project name) + the path of the file inside the project location. You can set the Base Path to / in Project | Properties | Debug . It applies to Run configurations as well. If you always use the documentroot of the site as the project location, it will work.
I ran across something similar where if I had a vhost named "test" I wanted to run everything for that project as...
http://test/<whatever_else>/
Here is my 3 step how-to to solve it, though I am not sure of any unintended consequences other than zend debugger not working.
From Eclipse, go to Windows/Preferences
Go to PHP/PHP Servers
Change Default PHP Web Server from http://localhost to http:/
The project will append the second slash and your project name if you just let it auto-generate.
Hope that helps someone. Helped me a ton.
You can modify the org.eclipse.php.server.ui plugin to get it the way you want.
Use the Plugin devlopment perspective of Eclipse to modify the plugin. The dialogs are available in
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/launching/PHPWebPageLaunchShortcut.java
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/ServerLaunchConfigurationTab.java
https://vsubhash.wordpress.com/2013/01/26/fix-for-url-auto-generate-bug-in-eclipse-php-pdt-plugin/

Do i have to tell IIS where my pdt PHP project is or should Eclipse/PDT have done it?

I've been reading through the docs and testing out what i can.
I've installed PHP, Eclipse + PDT, IIS settings etc. - I'm reasonably sure they are all set and should work.
Now I create a PHP Project, add a newfile.php, basic code like :
<?php
echo "hello";
Now I right click the file,Run as -> Web Page and i get a 404.
Eclipse has tried to launch http://localhost:80/Php1/newfile.php
IIS has no virtual or physical directory so the request fails.
Should Eclipse/PDT have done this mapping? Or do I need to? or should I create my projects under c:\inetpub\wwwroot
Eclipse / PDT does not configure your webserver for you. It looks like it's assuming that your document root is your workspace, so you could put all your projects in your wwwroot if you wanted to. You don't need to use the Run As dialog though, as long as the files are somehow visible to IIS.
Personally I like to either make a vhost per project, or use symlinks to bring the project directories into the wwwroot.

SVN Web Development - Path / OS Differences

What is the best way to deal with config / directory / OS differences using SVN to develop and deploy on 2 different platforms?
I am developing in Windows and deploying to Linux.
I'd like to use my home PC to test the files before using commit, I'm using a web framework and you must specify the paths to your system and application files for the framework. Obviously those are different on the 2 machines.
I have the option of using a linux server at home, as a last resort. I really like working with SVN using a GUI right now since I am new to SVN web development.
So what would be the best solution to config differences between my development and live servers?
There has got to be an easier way then changing the file everytime I commit it to the live server, which is really against what SVN is trying to accomplish in the first place.
One option is to keep the configuration files out of the repository - set them up on their own for both your local and server machines, and then don't touch them again unless you have to. (Using the svn-ignore: property can keep you from accidentally adding the config files to the repository later on.)
Another option is to try to use relative paths and then have the config/etc directories be in the same relative location to the working directory, even if they're not in the same absolute locations.
You can set a svn-prop (property) to ignore the config file. Forcing you to create one (manually or generated) specific to every installation.

eclipse pdt >> publish from workspace

I'm learning Eclipse PDT for PHP development. In pretty much all tutorials I've read they put the eclipse workspace inside the document root of the webserver (htdocs in my case).
Is this common practice? I mean; I don't like the configuration files on my (test) webserver. Isn't there a way to publish the changes to webserver's folder from the workspace elsewhere on the filesystem?
You can have the workspace in one directory, and projects in any other directories you'd like (not necessarily sub-directories of the workspace).
The location you specify as "workspace location" is the place where some configuration files (internal to eclipse) will be stored, I believe.
On my (Linux) machine, I have :
the workspace location in /home/squale/bin/eclipse-workspaces/1
projects are in /home/squale/developpement/ :
aggregator
php-src-5.3
...
On my Windows machine at work, I have :
workspace location is something like d:\bin\eclipse-workspaces\pdt-1\
I have a project on a hard disk (like d:\projects\project1 )
And another project on a network drive (which points to a Linux server, through samba)
That way, too, workspace files are in a really separate directory, not deployed to any server, and not in the SVN's checkout structure or even near it.
Putting the workspace inside the docroot is maybe easier, but works only if you have one virtual host, anyway (and not a couple of projects, so).
With older versions of Eclipse, sometimes, when Eclipse crashed, the workspace was totally corrupted, and had to be deleted ; not habing the projects' files in sub-directories of the workspace was really useful, by then.
You can also try setting up a local repository and using svn:externals, tho' I'm not a pro at knowing how to set those up.

Categories