A brief overview of how to setup the PHP edition of NetBeans follows. You would still need to consult Setting up your workstation for Joomla! development to learn about setting up your environment for Joomla! development. For the sake of brevity and not to "reinvent the wheel" we will provide references to further readings wherever we deem various topics are treated to a satisfactory extent elsewhere.
- NetBeans here and after refer to the PHP edition of NetBeans only.
- The following applies to all flavors of Windows and the steps should be similar or the same for other OS.
- In many of the cases there are several ways of achieving your goal, and the coverage here is just a guideline for a new beginner and doesn't claim on being exhaustive.
Installation and initial configuration of NetBeans
Prerequisite: to be able to install and run NetBeans you would need Java 6 or 5. If you don't have that installed, download it from http://java.sun.com/javase/downloads/widget/jdk6.jsp.
- Download NetBeans (http://netbeans.org/downloads/index.html) and make sure to download the PHP version. The installation is straight forward and amounts to clicking through the installation wizard which defaults to correct and workable values.
- Your first run after installation will install the auto-update plugin. Please do restart after installing the plugin.
- Your second run will find a number of updates which you are advised to install.
- Lets install the subversion plugin which we will need further down
- Go to Tools > Plugins menu
- Switch to the "Available plugins..." tab
- Look for a plugin with the name Subversion in the Base IDE category
- Select it by checking the checkbox to the left and click on the Install button at the bottom of the Plugins dialogue
- Restart after the installation is done and you now have a subversion client within your IDE.
- The start page of NetBeans consisting of related news can be turned off by unchecking the "Show On Startup" checkbox at the bottom of the screen.
We are now set to go and from here we will
- create our first hello netbeans project and do some minor debuggings
- we will step through downloading Joomla from the svn and make changes, create patches, apply patches and get updates from svn
Creating a project and debugging
- Start NetBeans and choose File > New Project menu and you will be presented with the "New PHP Project" wizard.
- Select "PHP Application" among the Projects option. Reference: http://netbeans.org/kb/docs/php/project-setup.html.
- In the next step you will be given the option of configuring
- Project Name - give hellonb
- Sources Folder - where the files created within the project will be located. Although NetBeans makes an attempt to locate the server DocumentRoot, it normally fails and defaults to Apaches default htdocs, which means if you have reconfigured DocumentRoot in your httpd.conf it will not be able to point it out for you, and you will need to point out the location manually as follows. Go to your DocumentRoot folder by choosing Browse and in your DocumentRoot folder create the project folder hellonb, select the folder and click Open.
- Put NetBeans metadata into a separate directory - NetBeans creates a folder named nbproject containing project specific IDE settings and metadata of the project to be created. If you are working with a project in which you are about to checkout from svn, as we will see below, having this folder in your project folder is not a desired option as it eventually will be included in your export. One way of not having nbproject in such exports is to relocate nbproject from its default location, the project folder. This is done by simply checking this checkbox and pointing out where the nbproject folder should be located, outside your project folder.
- In the next page of the wizard make sure that the Project URL is correct, in this case http://localhost/hellonb/, depending on your setup.
- Its now time to press the Finish button and create the project.
- Although NetBeans succeeds detecting where the PHP interpreter is located and thereby also xdebug, lets make sure that this is correct by going to Tools > Options menu and click to the PHP section (among the top horizontal bar of icons). In the General tab we should be able to verify that the PHP 5 Interpreter is the correct one and that the Debugger Port option contains the same value as the xdebug.remote_port parameter in the PHP ini file of the interpreter referred to.
- For those who've followed the instructions at http://docs.joomla.org/Setting_up_your_workstation_for_Joomla!_development to update php.ini with
set xdebug.remote_port=10000You need to go to Tools->Options and set the Debugger port to 10000 to match.
- With this behind us let us create our index.php file and put a simple statement, ex. echo "hello netbeans". Press F6 and the project should run by invoking index.php either in your default browser or one you would be able to configure in Tools > Options > General > Web Browser. With the given example, this should output "hello netbeans" in your browser.
- The topics of PHP debugging in NetBeans is excellently covered in http://netbeans.org/kb/docs/php/debugging.html. Another excellent resource regarding debugging with xdebug is the following comprehensive series, Introducing xdebug: http://devzone.zend.com/article/2803.
In this part we will see how easy it is to configure NetBeans to work with an SVN repository for the purpose of checking out, creating patches, apply patches as well as update repository (which we will not cover in this case).
- Create a new project of the type "PHP Application"
- Check if Netbeans created an index.php file in the Source Files directory (it's located right there under the 'Projects' tab). If so, delete it before you start the checkout. If you don't it might break the checkout process.
- Go to Team > Subversion > Checkout...
- (This step is done only the first time you are running the Subversion integration) You will be prompted with the message that a Subversion client is missing and given option to install it. Choose the easiest one "Get bundled Subversion binaries for Windows..." and click OK and click through the dialogue. Once the installation finishes restart.
- We will now resume back from step 2 above and in the Repository URL give http://joomlacode.org/svn/joomla/development/trunk and in User give anonymous and leave Password blank.
- Clicking Next. NetBeans will now connect to the SVN repository and ask you to provide:
- Repository folder(s) to checkout from in the repository which should remain unchanged, being "development/trunk" as it was included in the Repository URL in step 3. If the field is empty for some reason do provide development/trunk.
- Local Folder - Browse and point out you current project folder and
- uncheck the "Scan for NetBeans project" checkbox and click Next.
- Checking out the trunk will take some minutes to finish and you will see the task status on the right of the status bar at the bottom of the NetBeans window.
- Let us now make a dummy change to see how to deal with the various steps of creating a patch works.
- Open components/com_content/content.php and make a change, ex. by inserting a comment. Once we have saved our change you will see that files that have been changed since last SVN update are now highlighted with blue. Containing folder of changed files are highlighted with a blue badge. For more on this and other features please read http://netbeans.org/kb/docs/ide/subversion.html which even if geared towards Java developers applies mostly to PHP also, and shows most of the related features of NetBeans.
- Assuming now that is a solution to a tracker we would like to submit it as a patch and in NetBeans you will be able to do just that at several levels, either patch extracted from the file itself only, or at an upper level up to the project level. To do that: in the Projects or Files window, click on the folder or file you want to be the position from which all changes will be extracted as patch. Go to Team > Export Diff Patch... and give the location of the file to be created and click OK.
- Applying patches is analogus and all features related to SVN are found under Team or Team > Subversion menu.