sam keen's corner of the web

Your First PHP Development Environment

I’m teaching a PHP/MySQL course at the local community college this fall.  First order of business is to get everyone set up with a PHP development environment.  I decided to go ahead and post the strategy for the course as a post here in case it may be helpful others just starting out in PHP development.

This post is meant to help the individual who is just setting out to learn PHP web development and has no previous programming experience.  I’m listing a set of tools to help in that quest and giving some pointers as to how to initially configure them (though part of the reason these tools were chosen was that they require very little tweaking before you can start using them).

The OS used in this example is Windows, but all theses tools are cross platform (deliberately chosen for that reason), and the instructions will only change slightly for other OS’s.

Below are examples of installing a client (the web browser), a server stack (PHP and MySQL) and a code editor.  They’ve been chosen based on:

  • ease of install and use for someone new to all this technology
  • cross platform
    versions available for Windows and Linux flavors including OS X
  • extensibility
    In particular, Firefox and Netbeans.  As the user grows comfortable with these tools, they will discover that they contain many features to aid in web development.  (firefox: firebug, web-dev toolbar   netbeans: integrated source control, xdebug, etc)

PHP is a cross platform technology at heart so that enables a plethora of alternatives to the choices I’ve made above. So feel free to explore the other options and find the tools that work best for you.

Firefox

Install

Get the files from: http://www.mozilla.com/en-US/firefox/firefox.html

Install the firebug addon : http://getfirebug.com/

XAMPP

Install on Windows (windows 7 64bit edition shown)

Get the files from: http://sourceforge.net/projects/xampp/files

xampp0

xampp-install

XAMPP should do this by default, but be sure to install at C:\

xampp-intall-root

In service section check

  • Install apache as service
  • Install mysql as service

This causes those services to automatically start when Windows starts

xampp-services

Test install by opening a browser and going to http://localhost

xampp-browser-test

Netbeans Editor

Netbeans PHP IDE

Download here

Configure after Install

Apply Updates

Picture 59

Go to Help > Check For Updates

Test

Now create a new PHP application project called {YOUR NAME}-week1

netbeans-test1

netbeans-test2

Place the project in the XAMPP htdocs folder

Picture 64

Confirm the URL your project will be found at. (In our case, Netbeans should make the right guess here, so just confirm and click ‘Finish’

Picture 62

Editor Will Open and Netbeans will automatically create a starter index.php file for you

Picture 65

Clean up some unneeded windows

close these windows (you can always get them back later if you like)

  • navigator
  • files
  • services
  • palette
Picture 66

Now to make a few edits and create a new file so we can start to get familiar with the IDE.

Add some PHP

netbeans-add-php

See the file in a browser by clicking the green Play (>) button on the toolbar.  The Browser should open at the URL for the file.

Picture 67

create another file called new-file.php

  • Menu: File > New File
  • Choose category PHP, File Type PHP Web Page
  • Next
  • Change the filename to new-file.php
  • Finnish


Picture 68

In new-file.php create a hyper link to index.php and in index.php create a link to new-file.php
Picture 69
The resulting filesystem
Picture 70
Note, the nbproject folder is used by Netbeans (it is full of projects metadata).  You can simply ignore it (but don’t edit or delete it)

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>