Monday, January 28, 2013

Easy PHP Development on Windows

For the majority of my career I've been involved with the Windows stack of development products Visual Studio, SQL Server and so on. However From time to time I've had cause to get my hands dirty with some PHP coding both commercially and in a freelance basis.

Its been quite some time since I've used PHP but the other day a private client requested that I use it to deliver a website and I had to set about building a development environment for this on my PC. As it happened pretty much all the work could be done client side (jQuery, Google Maps API etc) so all I really needed was an IDE and the PHP interpreter.

There are really only 4 steps to getting a basic PHP environment setup which I've tried to detail below as succinctly as possible!

1. Download the software

PHP Binary Interpreter:
http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip

NetBeans 7.2.1 IDE:
http://netbeans.org/downloads/

2. Extract & add PHP location to PATH Environment variable
Create a directory for the PHP files something like:

C:\Program Files (x86)\php-5.4.8\

Extract the php zip file to the above directory.

If you're using Windows 7 hit "Start" and type "Environment" then click "Edit the system environment variables" when the search comes back - for me this is the second option appearing on the start menu.

In the "System Properties" window on the "Advanced" tab click the "Environment variables" button which is on the bottom right just above the "OK", "Cancel", "Apply" buttons.

In the "System variables" list (second one near the bottom of the window) scroll down until you see "path", left click this item and then click the "Edit" button. Scroll to the end of the text box (End key will work best here). Then type/paste the following:

;C:\Program Files (x86)\php-5.4.8

Modify the above accordingly if you've chosen to install to a different location. Ensure it starts with a semi-colon to "close" the previous variable.

3. Install & configure NetBeans
Run the NetBeans installer accepting all the defaults (or changing them where necessary). Open the IDE and then click "Tools" from the menu then Options then PHP. Click the "Browse" button next to the "PHP Interpreter" label and text box and navigate to the PHP directory you created earlier then click on the php.exe file and click "OK".

4. Reboot & Create New Project

Because we added an environment variable we should now close everything down and do a reboot. Once you're back into Windows start NetBeans and create a new project - choose the "Built in Webserver" option when prompted and you're good to go; write some PHP and then click the little green arrow to start!




4 comments:

thiru it jobs said...

that's great, thanks for the sharing this one with us. i worked this one in my pc and got a better results. today's php development plays a vital role for creating a websites.

anna harris said...

Thanks for the windows version but, I want Linux version of it...

bUKaneer said...

@annaharris the linux version should be very similar - use APT (or whichever package manager you have) to download the PHP and NetBeans packages - then load NetBeans and configure. Should be easier on linux than windows!

Unknown said...

Thanks for sharing such a nice post regarding PHP development. Keep it up!
hire a ASP.NET developer