Thursday Oct 23, 2008

Install Apache on Windows Vista

This night I have tried to install Apache and PHP on a Windows machine with Vista. I thought that it will take just few minutes as it usually takes on Ubuntu, but it was not. I wanted to install the Apache to the default location (C:\\Program Files/Apache Software Foundation/Apache...). The reason for this was that NetBeans is looking in the default instalation location and if exists, then it offers in new project wizards etc.

So I downloaded the msi installer of Apache and run it. The installation executed nice and correctly. The Apache was running and the url http://localhost shows known page It works! .

But when I tried to copy a file to the document root or create the project from NetBeans inside document root, then it failed. OK, it will be due to a rights permitions, I thouhgt. I noticed that htdocs folder is marked as read only. I opened the folder properties and uncheck the Read Only checkbox. Windows displayed nice progress bar that showed the progress of setting read only attribute to false for all files in the folder as fell. So I tried to copy a file into htdocs folder. It failed! The folder was still marked as read only. Hmmm, strange Windows didn't inform me that the previous action failed. So I tried to change the read only attribute for Program Files and all subfolders in Apache folder. The  same result. Still were read only, even that Windows showed the progress bar, no failed message.

Now was the time to use Google:). It was surprising for me that many people had exactly the same problem as I. Some of them give up and recommend to install back Windows XP. But then I have found the solution. On Molecular Sieve blog is an entry with steps how to solve the problem. Big thanks to author for this.

After applying the steps I can copy files and create project in the document root of Apache, which is installed in the default location.  Still the folders are marked read only, but write in the folder is possible :).

During this exercise I found a few interesting information. Like that the msi installers install the applications as SYSTEM user, which is something like root user in linux. After the installatin the Apache is running with all priviliges as SYSTEM user has and the php and other cgi scripts has also rights of SYSTEM user. Is not very save to expose such Apache publicly. You can find at internet steps how to solve it.

What is your experience with running Apache, XAMP under Vista?

Thursday Oct 09, 2008

Code completion for a class field

NetBeans are able to offer code completion for class fields of a PHP class. Because PHP is not a strict typed language, you can help to NetBeans to find out the type of a field.

Let's have a simple example: 

The example doesn't show good practice, because the class fileds shouldn't be accessible outside the class, but for explanation it's enough.

One way how NetBeans are trying to find out the type of a field is that it looks through the class constructor. In our case in constructor there is expression that assigns new Address object to the $address field. So NetBeans supposes that the field is Address type and code completion for $this->address-> suggests $street and $city fields from Address object.

This functionality was added recently and works only in the file, where the class is defined and still there is a space for improvements.

The second way is to specify the type of a field through PHP Doc. It's more universal, the field doesn't have to be initialized in the constructur. As you can see on the picture, the type is also displayed in the code completion window.  NetBeans helps to write the PHP Doc,  write /\*\* one line above the field and press ENTER. Then NetBeans will generate appropriate PHP Doc. Also you can use code completion after @var tag to obtain all available types from the project in the code completion.

Tuesday Oct 07, 2008

How to create project for every WordPress plugin

In the previous entries about WordPress I have describe how to develop a WordPress plugin inside WordPress. This entry describes how to set up a project in NetBeans for every plugin separately. 

Let say that I develop many WordPress plugin. The folder structure is displayed on the picture.

I have folder WordPressPlugins that contains all plugins which I develop. Also I have one copy of WordPress sources in WordPressSources folder jut only for development reason. I will explain the reason later.

Then there is wordpress folder under Apache document root, which is accessible through the URL http://localhost/wordpress.

Now create the next plugin. Open new PHP Application wizard and call the project for example AnotherWPPlugin. The source folder for the project will be under the folder, where all WordPress plugins are developed. NetBeans will create in WordPressPlugins folder AnotherWPPlugin folder with the sources and nbproject folder for NetBeans metadata. The second step in the wizard should look like on the picture.

Basically similar approach is if you want to create project for an already existing plugin. 

In the next step you specify, how the project will be run. Run Configuration should be Local Web Site. The WodPress is reachable under http://localhost/wordpress URL. Also you have to say to NetBeans that the plugin sources has to be copied to the WordPress. So check the Copy files form Source Folder to another location and browse the plugins folder under the Apache's documented root.

So the third step of the wizard should look like:

After creating the project go to the Project properties and add the WordPressSources folder into Include Path. The reason is that we want to have the WordPress API in code completion. Sure we can put into Include Path the wordpress folder located under the Apache's document root, but then you will see the statements from the developed plugin in code completion twise. The first one from the sources folder and the second one from the plugins folder under document root.

NetBeans will create index.php file. You can use it and change the content to be an entry point for the plugin. More here.

Monday Oct 06, 2008

How to make the default font size bigger

Sometimes I need to increase the default font used in NetBeans. For example for a presentaion. Fortunatelly it's simple to change the default font size used in editor,  menus, dialogs, etc. You can run NetBeans with argument --fontsize xx, where xx is the required size. The --fontsize argument applies to fonts used in menus, dialogs and most components in the IDE.

You can run NetBeans with --fontsize from command line:

on Windows: netbeans.exe --fontsize 14

on a linux machine: netbeans --fontsize 14

Or you can set this option permanently in netbeans.conf file.

Gnome Specific
If you are running NetBeans under Gnome with the GTK L&F, then NetBeans uses the default Gnome settings including font size. If you want to change the font size for NetBeans you must change font size in Gnome Preferences -> Appearance -> Fonts. Alternatively you can use Metal L&F with --fontsize option. Use --laf jvax.swing.plaf.metal.MetalLookAndFeel to run with Metal.

Thursday Oct 02, 2008

Anti-Aliasing Font in the Editor

NetBeans editor follows the system setting of anti-aliasing font.  On windows you have to set up ClearType method to smooth edges of screen fonts, which is not the default value on Windows XP. I think that Windows Vista uses ClearType method as the default one. Also the default value in both cases can depend on your hardware. To change the method go to the Display Properties and in Appearance tab open the Effects dialog.

When there is the default value Standard, then NetBeans doesn't provide anti-aliasing. The picture below shows the IDE without anti-aliasing or when the method to smooth edges of screen fonts is Standard on Windows XP.

The next picture shows the IDE, when anti-aliasing is switch on.

It's better to see the differences, when the picture is zoomed.

The native anti-aliasing on Windows is available from JDK 1.6 (Update 10). You can disable it, when you start NetBeans with -Dawt.useSystemAAFontSettings=false from command line (netbeans.exe -J-Dawt.useSystemAAFontSettings=false) or you can also add this property to the netbeans.conf file. 

If you use Gnome, then the method of anti-aliasing you can set up in System -> Preferences -> Appearance.

If you don't like the NetBeans default font, you can change it in Option dialog -> Fonts & Colors tab. In the Category list select Default item and change the font. 

For example this is Lucida Console 14.

Wednesday Oct 01, 2008

Setting up Your Web Browser

This tip explains how to set up different web browsers to view a project or a page. Other web browser configurations are helpful if you want to view a page in Firefox, Internet Explorer, Opera, Safari or any other browser than the default system one. It can also help you when you need to test your applications with different versions of a browser.

After installation or when running the IDE with a fresh userdir, NetBeans uses the default system browser. When you invoke Run or Debug on a PHP project that uses Local Web Site or Remote Web Site Run Configuration, a browser is launched and the project URL is displayed in the browser. Run and Debug Single File actions work in a similar way for individual PHP or HTML files. 

You can change or add a new browser configuration in the Option dialog.

In the Web Browser combobox you can select from predefined configurations. When you press the Edit... button, you can change the existing configurations or you can simply add a new one.

Thursday Sep 25, 2008

Introduction to Ajax for PHP Web Applications

There was recently published new tutorial Introduction to Ajax for PHP Web Applications on NetBeans site. The tutorial provides an introduction to Ajax and demonstrates some of the features in the NetBeans IDE that allow you to program faster and more efficiently when working with Ajax-related technologies. In the example application, you can create an entry field with autocomplete feature.

Tuesday Sep 23, 2008

Using Zend Framework with NetBeans IDE

My personal experience in setting up Zend Framework to work with NetBeans IDE.

[Read More]

Wednesday Sep 17, 2008

Create a WordPress Theme with NetBeans PHP IDE

Toni Epple has written a nice tutorial about customizing a WordPress theme. You can read it here.

It is nice to know that the result of our work is useful and helpful, even if we haven't fully finished the first version of PHP support yet.

Friday Sep 12, 2008

Displaying Documentation Window Next to Completion Window

Do you use a wide screen? Or have you noticed that the documentation window hides the text in the editor at the moment when you want to see one or two lines above the caret? A few days ago I was discussing with the editor guys, why NetBeans displays the documentation window above the code completion window. As a result there is issue #144362, which was resolved at the beginning of this month.

[Read More]

Tuesday Sep 02, 2008


I work with development builds and I run multiple NetBeans instances at the same time. I have always one instance running where I develop and a second one for testing purposes. Also I change the NetBeans build almost daily. Fortunately there is the  --userdir switch.

This switch has one parameter and this is a path to the folder where NetBeans stores all settings, including information about opened projects.  Basically it's something like a workspace. If I need to work on PHP suppport, I start NetBeans with this command

./ --userdir /space/netbeans/userdirs/php

If I need to fix something in Java Web Support I use

./ --userdir /space/netbeans/userdirs/javaweb

and for testing php build

./ --userdir /space/netbeans/userdirs/phptest

Because  I use development builds, sometimes the userdir can be damaged and I have to delete it and start NetBeans with a clean userdir, but this is not a big issue. Sure, I can lose all my settings, but I have to be aware that I work with the latest builds and this can happen. On the other hand, I have to delete the userdir very rarely.

I don't use installers, I always download NetBeans as a zip file. These are available on nightly build download page, where OS Independent Zip item in has to be selected in the Platform combobox. There are also really fresh builds publicly available on the continual building machine. The PHP builds are available here. There are available only as zip files. The zip file can be unzipped anywhere on your machine. Then just execute the or netbeans.exe, which is located in the bin folder, with the --userdir switch.

Sunday Aug 17, 2008

My first WordPress plugin in NetBeans

When I read Jan's tutorial how to configure WordPress in NetBeans I started to think, how it can be difficult to write a plugin for WordPress and whether NetBeans can help me in this. This entry is tutorial how to write simple plugin for WordPress.

What the plugin will do? The plugin will look through content of displayed entries to replace NetBeans with link to site. It's simple and it should take only few minutes.

[Read More]

Wednesday Aug 06, 2008

Configuring a NetBeans PHP Project for WordPress

I've been experimenting with WordPress a little bit lately while setting up a blog on my personal web server. The installation was completely smooth, but I was interested in some of the WP internals and also wanted to get a better understanding of what it takes to develop WordPress extensions. So, I set up a NetBeans PHP project for my experiments.

I thought other folks might be interested in this, or perhaps, would like to see how to set up a project in NetBeans for their existing PHP applications in general. Therefore, I wrote this brief tutorial and published it in NetBeans wiki. In the future, I'd like to write another tutorial about developing a real WordPress plugin.

 Comments welcome.

Wednesday Jul 30, 2008

How to manage templates in NetBeans II

My last entry "How to manage templates in NetBeans I" introduces to the file templates in NetBeans. This is probably more interesting part, which describes how to change the content of a new file during creating from a template. 

[Read More]

Tuesday Jul 29, 2008

How to manage templates in NetBeans I

NetBeans contains many predefined templates for creating new files, but these templates don't have to fit your needs and you want to change or create new templates. I will try to explain it from PHP point of view, but this is generic NetBeans future, no PHP specific. Originally I have prepared one blog entry about this, but then I realized that this is too long. There is the first part, which describes "static" templates.

[Read More]

This blogs is written by NetBeans developers who contribute to the PHP support mainly.


« July 2016