Test Your PHP Apps On Your Own Computer

servers

I am often asked about by people how they should test their PHP applications. Because PHP is a server-side programming language, you can't just open the file in your web browser, like with HTML or JavaScript. You need to upload it to a server where the script can be run. But what if you don't want to rent space on a server, or if you want to make testing of PHP scripts much faster?

The solution is to setup your own server. However, it can be quite difficult and time-consuming to install Apache, make the appropriate configurations, then setup and configure PHP and MySQL. Thankfully, there is an excellent free and open source Apache distribution that makes server setup as easy as it can get.

XAMPP

XAMPP stands for X, Apache, MySQL, PHP and Perl. The X means that XAMPP is cross-platform, including distributions for Linux, Windows and Mac OS X. Included in the package are the necessary Apache, MySQL, PHP and Perl packages, plus plenty of other useful tools such as phpMyAdmin, OpenSSL, and more.

The great thing about XAMPP is that setup is incredibly easy. The entire setup process for your server can be done in about two steps:

  1. Download XAMPP.
  2. Extract it.

Once that is done you can just fire up the server and start adding your files to the appropriate directory. Easy, huh?

After having extracted the files, your testing environment is just about setup. Add the files for your project to your htdocs directory (/opt/lampp/htdocs/ on a Linux setup), start the server, and you can then point your web browser to http://localhost/ to view your fantastic setup!

When the server is running, http://localhost/ acts as the URL from which to access your server. It can only be accessed by you, and no one else.

Another great feature in XAMPP is the fact that it is basically just a package using Apache, which can be extended with new features. For example, you can easily add support for Python and Ruby on Rails for testing your web applications.

For more information on XAMPP, check out the website, for excellent documentation and detailed installation instructions.

So you may want to consider using XAMPP if you want to have a testing environment on your computer that is quick and easy to install and setup, is very customizable and is completely free and open source. If you do not use XAMPP, what do you use for a testing environment, and why?

Stay Updated

Did you enjoy this post? Don't miss a single post by getting free updates!

6 Comments

  1. Spencer B.
    April 7, 2010

    Personally I use WAMP ( http://www.wampserver.com/en/ ). I tried using XAMPP in the past but I seem to like WAMP much better. It seems more straightforward to me, as it works great straight out of the box. I suppose the only downside is that it is for Windows only.

    • April 7, 2010

      I've heard good things about WAMP as well. I have never tried it, though, because I do not have any computers running Windows.

      • Kyle Zhou
        April 8, 2010

        I got my friend to use Wampserver (actually i just installed it) and he uses it to run his maplestory private server/forum/site. It works well but it does block the remote admin (like restart server w/o rdp access)

  2. joe
    April 7, 2010

    Personally I choose to use Zend server ( ce edition). It can be bundled with optimizer and of course a full debug and php environment with other zend tools. Its more reliable and has a better ui. Give it a try you will never go back to xammp.

    http://www.zend.com/en/products/server-ce/

    • April 7, 2010

      Well, then. I guess I might just give it a try some time!

Trackbacks/Pingbacks