Because this chapter is written under the assumption that you have a beginner-level understanding of PHP scripting, it may be safe to also assume that you have a server environment to develop on. But because it's never safe to make such assumption, we have provided the necessary information to create a server environment in which you can duplicate the examples in this chapter.
The server setup that we are using for the examples in this chapter runs on a Microsoft Windows server. The environment works the same on other servers (Unix, for example), but you will need to download the appropriate files and follow the instruction for the particular server you are working with. To duplicate the examples in this chapter, you will need a server environment with three components:
If you are not familiar with any or all of these components, it may seem like a daunting task to set it all up yourself. Don't fear. It is much easier than you think and there is a world of support out there to help you understand the technology behind it all. The best thing to do is to find a friend or colleague who is familiar with setting up the above-mentioned environment, and have them help you. Each component's website is also jammed packed with tutorials, and the best thing to do is just follow the readme.txt (or install.txt, or setup.txt) files that come with each component's installation files.
We almost forgot to tell you the best part about APACHE/PHP/MYSQL developmentit's free! That's right, all three of the components needed are open-source projects with years of development and support. Thought that you might like that!
Installing Apache Server
The Apache server is the "environment" that PHP and MYSQL run in. The Apache server can be downloaded from http://httpd.apache.org/download.cgi. The current version at the time of this writing is 2.0, but we will be using 1.3 because it has been in use for some time and will be the version most hosting companies are currently running on their servers (2.0 also does not offer us any features needed over 1.3; the choice is yours).
The Windows download is a self-extracting installation file. Follow the instructions and refer to the documentation at http://httpd.apache.org/docs/install.html if needed.
PHP can be downloaded from http://www.php.net/downloads.php. The current version at the time of this writing is 5.0, but we require that you use 4.3 because it has been in use for some time and will be the version most hosting companies are currently running on their servers. PHP 5.0 is not just an upgrade, but a reconstruction of PHP and will not be widely supported for some time. (Hosting companies are starting to offer special servers with PHP 5.0 support, but at the time of this writing support for and development with PHP 5.0 is very limited).
After you download and extract the files, open the install.txt for installation instruction. The installation and configuration for PHP is mostly manual, compared to APACHE being a program installation, but the instructions are simple enough and should be easy to follow.
MYSQL is the database that is used mostly when you're working with PHP. MySQL can be downloaded from http://dev.mysql.com/downloads/index.html. The current recommended version at the time of this writing is 4.1; 5.0 is currently in development, but we recommend sticking with 4.1 because it has been in use for some time and will be the version most hosting companies are currently running on their servers.
The Windows download is a self-extracting installation file. Follow the instructions and refer to the documentation at http://dev.mysql.com/doc/mysql/en/windows-installation.html if needed.
Having MySQL installed and working with MySQL are two different things. You can work with MySQL through the command prompt (Windows) or the console (Unix), but we prefer to use a web-based alternative that is much more user friendly, PhpMyAdmin. PhpMyAdmin can be downloaded from http://www.phpmyadmin.net and is very easy to set up. After you download the appropriate files and extract them, open up Documentation.txt (on Windows you will need to open this up in WordPad instead of Notepad because of some rich-text formatting) to find the installation instruction.
We recommend that you install each of these components yourself, simply because the education you gain will help you in the future, as well as make you more comfortable with setting up server environments. As mentioned before, it is not as daunting a task as it may seem, and the World Wide Web is chock full of help. Fear not!
Now That It's All Installed
After you have your server set up, you'll want to make sure it works properly.
Learning More About PHP
You may already have a pretty good understanding of working with PHP, but the language has as many functions as the day is long. If you want to learn more about PHP scripting, we recommend that you go straight to the source at http://www.php.net.
PHP is a very powerful language and the more you work with PHP and Flash, the more you will want to do with PHP. Whenever working with PHP I always have php.net open in a browser window to do quick searches. You would be amazed how many times you will learn something new that makes working with PHP easier.