Adding more source folders to a NetBeans PHP project - php

Is it possible, with or without plugin, to add more source folders to a PHP project, just like in a Java project?
I have downloaded and tested the Java version of NetBeans, and there is clearly possible to add more source folders. But not in the PHP version?

you can add paths for all newly created PHP projects from:
netbeans options > PHP section > Global include path
or you may add project specific include paths in a project's "project properties" (right click on a project in the projects view", and then choose "PHP Include Path" from the left side section.
although you are not allowed to edit a project included sources. you might as well create an additional project in Netbeans and call it like "my-include-path", then add all the folders in your desired include paths to this project. now you can edit your included files in this project.

When you right-click in the projects panel (Netbeans 6.9.1), there's an option 'Project Group'. This allows you to add the current projects (In this case the php and the js project) to be grouped and opened as one.
Also useful to automatically open additional projects used for reference.

Under project properties, the source folder is only one.
However, you could add folders to the PHP Include Path if you are trying to use files from another folder.

At this time, it looks like NetBeans PHP projects does not support multiple source folders.
I have added a feature request to the NetBeans' Bugzilla: http://netbeans.org/bugzilla/show_bug.cgi?id=180889

"Global include path" and "PHP include path" does not work for me.
My personal solution is to add the extra_path before the include/include_once statements in this way:
set_include_path(get_include_path() . '$extra_path);

Related

What is the ".phpintel" folder at the top of the Laravel file structure?

I am just noticing that there is a .phpintel folder at the top of the Laravel file structure. Where did it come from, is it necessary and can I gitignore it?
phpintel is a common sublime plugin. PHP code scanner and analyzer for code intelligence within PHP projects.
It creates .phpintel directory like .idea for Phpstorm and it should be included to .gitignore list of project and contains local project related settings and history for it.
You can ignore any hidden (and generated) data
You will find phpintel ignored in many .gitignore project file, such as:
postmark-php/.gitignore
Zizaco/entrust/.gitignore
...

NetBeans IDE and project setup

I set-up three projects in NetBeans IDE, two are html projects and another one is php project.
When I test run, the project php's index.php (Main home page) is wanted to be loaded first. Then it will load another index.html files (two sub pages).
But now when I run, the first html project's index.html is always loaded first since it is at the first position at IDE because of alphabetical order in project name.
How can I load php project's index.php file?
Whenever you create project on NetBeans, you can specify the URL of project in the "Project URL" field.
Please see the below screenshots that will help you.
Screenshot : Here you can see "Project URL" field, with the help of this you can specify you project's index.php file

Can you turn a folder of PHP files into a netbeans project?

I have a folder with several subdirectories containing PHP files. At the moment I open each file individually in Netbeans. However, I would like to open this folder as a project, so I can use features like searching for a line throughout the entire project. Is this possible in Netbeans? What would be the best way to achieve this?
Create a new project, set sources directory to the one you have with current files
(might want to back up the files before if anything goes wrong).
Go in Netbeans. Select Files->New Project. A window will open, in that select PHP in Categories. Click Next. In Project Name give the name of your project(as seen in netbeans), in Sources Folder select the path to your project and click Next. In Run Configuration Make the settings according to your requirement to run the project. Now in PHP Frameworks Select ypur desired framework or just leave it blank and click FINISH.
You will See your project in Netbeans now.
Go to file->New Project and select PHP in category and follow the instruction.
In Source folder you need to choose your files folder so that it get listed.
go to FILE->new Project->select php in categories in left pane and php application with existing sources as Projects *in the right pane* ->next -> next till finish
When you add any directory in netbeans as a project, it add its only directory under the project directory. So if you need to add the numbers of directory in netbeans being a project, then i would like to suggest firstly to collect all directory in parent directory. then add it as a project.
Here is an explaination:-
directory- dir
lets you have dir1, dir2, dir3, dir4.
and according to you mentioned above all dir are projects.
You have to create a dirA and all dir1, dir2, dir3,and dir4 are subdirectory of dirA.
so the folder under dirA nbprojects(created by netbeans) will take care of all directories being the subdirectory of dirA.

How to set a default directory for NetBeans PHP projects? [duplicate]

This is only a minor annoyance but if I can figure this out I'll be very happy.
Is it possible to change the default project directory in Netbeans 7? I don't know if it's relevant but I have the PHP Netbeans distro.
Thanks!
In new netbeans 7 search file: D:\Users\YourWindowsUserName\.netbeans\7.0\config\Preferences\org\netbeans\modules\projectui.properties
Delete: *RecentProjectsDisplayNames.*8, *RecentProjectsIcons.*8, *recentProjectsURLs.*8 for cleaning recent projects.
Change projectsFolder for default projects folder when creating new one
To find out the location of the projectui.properties file for the latest versions of NetBeans for various operating systems:
http://wiki.netbeans.org/FaqWhatIsUserdir
Under Linux, you can change it in the Netbeans configuration directory: .netbeans/6.8/config/Preferences/org/netbeans/modules/projectui.properties
I believe that Netbeans will remember where your last project was created and uses that as its default. So if you create a project and choose a different directory than the default, then that directory will now be the default.
If you are asking for how to set the main project so that it runs by default and is debugged by default, then:
Run > Set Main Project, and select your project.
This will highlight in bold the name of the folder of your project in the files windows, usually on your the left hand side.
Instructions for Mac, based on some of the answers above:
Make sure NetBeans is closed.
On a Mac, the edit ~/.netbeans/7.0/config/Preferences/org/netbeans/modules/projectui.properties
Look for a line that starts with projectsFolder=
Example:
projectsFolder=/Users/<your username>/NetBeansProjects
If this line does not exist, add it with the full path to the directory you want to use. And of course, if it already exists just edit it to your desired path.
In newer versions, right-click on the project you want to move in the 'Projects' tab, and then click 'Move'. This will allow you to move the project to a new directory.
If you just want to move the projects in a Project Group, then do this:
( I am using NetBeans 8.0.2 )
( I have a Project Group based on root directory, and I imported all projects under that directory. )
Use Explorer to move (: copy if paranoid :) the projects' directories to the new location.
Edit the file C:\Users\<yourName>\AppData\Roaming\NetBeans\8.2.0\config\Preferences\org\netbeans\modules\projectui\groups\<theGroup>.properties
Change the path entry to the new location.
Open NetBeans and make sure Files / Project Groups ... is looking at the group of projects you think it is.
On my Windows 7 it's Users\\AppData\Roaming\NetBeans\7.2.1\config\Preferences\org\netbeans
I use Netbeans 7.0.1 on Windows 7.
For me the projecui.properties file was in C:\users\.netbeans\7.0\config\Preferences\org\netbeans\modules\ directory. About the fourth line down is a property called projectsFolder. Just change that to the folder you want and you're done!
Caveat: this is Java, so if you have a backslash, you have to double it up (C:\folder would be C:\\folder). It seems like I did this before within the application itself, but I could not for the life of me find it. I realize this is an old thread, but it was my first hit googling my problem, so I'm sure others will as well. -Mike
On Windows you could find that file in:
[%USERPROFILE%|$Env:UserProfile]\.netbeans\...\projectui.properties
Found this, http://wiki.netbeans.org/FaqAlternateUserdir, but did not have success with it. Neither the command line value nor netbeans_default_userdir from netbeans.conf were persisted to projectui.properties.

How to add project to Netbeans when all source files are not in webroot?

The directory structure of my project is like this:-
/var/www/includes/
/var/www/classes/
/var/www/public/css/
/var/www/public/js/
/var/www/public/index.php
The webroot is /var/www/public, so accessing the test domain localhost.dev would serve the files inside the public directory and hence would run /var/www/public/index.php. No need to access like localhost.dev/public/index.php
The problem is when I create the project in Netbeans, I have to set the index file so that the project can be debugged using xdebug and Netbeans.
So when adding the project I provided /var/www as Project source folder (Sources Folder) as the includes and classes are in this folder. In the next project configuration screen (Choose Project > Name and Location > file path is taken as Run Configuration), I'm asked for the Project URL and the index file. Since the index.php file is actually under the /var/www/public/, when I browse the file and select it, the url to index page is taken as localhost.dev/public/index.php instead of just localhost.dev/index.php. This is preventing me from debugging the project.
Can anyone please point out how to add projects to Netbeans when all the source files are not in web root and the project is to be debugged using xdebug.
I think its a bad practice to put all the project files directly in /var/www.
I think you will never see that in real deployed projects. So my first recommendation will be to change the way you are structuring your project. If that's not possible, in Netbeans select /var/www/public as the Project folder.
If Netbeans need references to the folders in /var/www, create symbolic folders inside public pointing to those in /var/www.
The last resource you have is to create a rewrite rule in Apache to make localhost.dev/public be the same as localhost.dev. You can look for this in Apache documentation.
I have a similar set up with one minor difference: my setup uses a remote site on my local development server. On the "Run Configuration" window of the project properties, I set "Run As" to "Remote Web Site (FTP, SFTP)". I don't think this affects the information in my answer, but I'm mentioning it just in case.
Go to the "Sources" window of your project properties, find the entry for "Web Root", click "Browse" and select the /var/www/public directory. That should cause xDebug to use localhost.dev/index.php. You'll notice when you go to the "Run Configuration" window and browse for the Index File that the browse window will start in "public" rather than "www".
An important note about this type of configuration that caused me a great deal of frustration.
When using xDebug, you'll want to be able to set breakpoints in and work with the files outside of the web root (public) directory. Because you've set the web root to /var/www/public, you won't be able to work with the files in /var/www/includes or /var/www/classes.
The thing you need to do is to add the files outside of your web root to the Global Include Path.
There are two methods for adding directories to your Global Include Path, which one you use depends on how you've configured your project.
In your case, the external directories are included in your project, so you need to add them via the "Options" interface. Go to Tools->Options and select the "PHP" tab, then add the /var/www/includes and /var/www/classes folders to the Global Include Path.
The other method for adding files to the Global Include Path is for files that are located outside of your project source folder. For directories like /var/folder_outside_www/, you use the "PHP Include Path" window in the project properties.
I haven't found a better way but I use this steps:
Menu:Project Properties -> Link:Run Configuration -> Button:Advanced
Debug URL, choose: Ask Every Time
Path Mapping, Server Path: http://localhost.dev/ ,Project Path: /var/www/public/
Now, when you start Debugging process, Netbeans will display Specify URL pop-up which you can change from http://localhost.dev/public/index.php into http://localhost.dev/index.php
Set /var/www/public as project folder (contain netbeans project folder) and include in project properties /var/www/includes/ and /var/www/classes/ as global include directories. Or best way use PHPStorm.

Categories