Mar 2008
26
07:34pm

I realized that a lot of people who want to learn PHP are having hard time getting started with it – not because PHP is difficult to use or understand but simply because they don’t know where to start. Because of this, I decided to write this short how-to on getting started with PHP. It covers all the necessary stuff to setup Apache, PHP, and MySQL as well as to install one of my favorite PHP editors.

Without further ado, let’s go on…

The simplest way to install everything you need to run PHP web pages on your workstation is to install XAMPP. The beauty of using XAMPP is that it can be installed on any of the following operating systems:
XAMPP Logo

  • Microsoft Windows
  • Linux
  • Sun Solaris
  • Mac OS X

As for XAMPP, it means:

  • X – any of the four operating systems above
  • A – Apache (the web server that serves your PHP web pages)
  • M – MySQL (the SQL database)
  • P – PHP
  • P – Perl

It used to be called LAMPP where L stands for Linux but they decided to change L with X since it’s not just Linux anymore. So how do we install it? Simple, go to http://www.apachefriends.org/en/xampp.html and download the correct installer for your system. To make it even easier for you, I’m including the links to the installer download pages here.

To install, just download and follow installation instructions. (C’mon, you don’t expect me to spoon-feed you everything right?)

After you’ve installed XAMPP, all you need to do is run it. In Windows, all you have to do is run XAMPP Control and start each service that you want. Basically, you’ll want to start Apache and MySQL. After you’ve started Apache, you can now give it a try by browsing to http://localhost/. That should show you the XAMPP welcome page.

XAMPP Control Panel
The XAMPP Control Panel

XAMPP Start Page
XAMPP Start Page (http://localhost/)

XAMPP also comes with phpMyAdmin which allows you to manage your MySQL databases via browser interface. You may access phpMyAdmin by browsing to http://localhost/phpmyadmin

phpMyAdmin
phpMyAdmin (http://localhost/phpmyadmin)

So where do you put your PHP pages so that they are properly served by Apache? With XAMPP, it goes in the htdocs folder of your XAMPP installation. I recommend that you create separate folders for your projects so you can easily manage them.

Now that you have Apache/PHP and MySQL running through XAMPP, the next thing for you to do is install an editor. Any plain text editor such as Notepad will do. However, there are better editors out there that provide syntax highlighting and debugging functions. One of my favorites is Eclipse PDT (PHP Development Tools). It runs on Java which means it is cross-platform.

Eclipse PDT Splash Screen
Eclipse Splash Screen

The easiest way to install Eclipse PDT is to follow these simple steps:

  1. Go to http://download.eclipse.org/tools/pdt/downloads/
  2. Click the Release Build
  3. Download the All-in-One package for your operating system
  4. Uncompress the downloaded package and run Eclipse from there

If you did it correctly, then you should see Eclipse’s IDE. Mine looks something like this:

Eclipse PDT Intergrated Development Environment
Eclipse PDT Integrated Development Environment

One nice feature I like with Eclipse PDT is that it has a list of all the functions supported by PHP making it easier for me to write thousands of lines of code. Also, since it’s an IDE, it also keeps track of your variables, functions, and classes.

Quick but important note, it’s also best to keep a copy of the PHP manual accessible. If you’re always online, then the manual is just a click away. Typing php.net/str_replace on your browser will take you to the documentation of the PHP’s str_replace function. You may also want to download a copy of the PHP manual if you’re not connected to the internet all the time.

There you go. If you’ve successfully installed XAMPP and Eclipse then you already have the basic needs in getting started with PHP.


Share this Post through Social Bookmarking
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Tags:

Leave a Reply