I began taking on-line development classes offered at my local college, and students had to upload their scripts and files via FTP to a school server for processing. The necessary security precautions required a boatload of username/password combinations that were strictly enforced and a pain to remember. Getting my project onto the school’s server was possible, but it was easier for me to develop my project locally before uploading them to where they eventually needed to be.
This article will explain how a development system solves such a problem and how to install the popular Windows-based web development platform WAMP. As a relative newcomer to the PHP language, I hope this article speaks directly to other new programmers who are interested in honing their development skills to eventually become PHP masters.
The Development Server
Every programmer needs a place to write and develop their programs.
A development system is a computer with a group of applications that are installed that perform the same tasks as on a web server. The benefits of this is being able to develop and test your scripts locally without having to upload them first, and the security of maintaining your files locally until they are ready for their intended purpose. Plus you don’t have to be connected to the Internet while you work. We are pretty much always on-line nowadays, but every so often you can find yourself without a connection to the web. Who knows, you may want to crunch code on a laptop while sitting on a beautiful secluded beach.
What is a WAMP Server?
A WAMP server is a computer running these applications:
- Windows OS
- MySQL Database
There are many variations, and you may have come across the term LAMP server before. This is essentially is the same as WAMP except it is based on the Linux operating system.
There are also various ways to construct your WAMP server. If you are bold and fearless, you can download and install Apache, MySQL, and PHP individually on your machine, and if all goes well you will end up with a sweet WAMP server. Or if you are like me, you will take the advice of many wise men and install a Windows-based server package of which there are several. I choose to install WampServer. WampServer is open source, free to use under the GPL license agreement, relatively simple package that automatically installs everything you need to start developing.
WampServer even includes a great graphical tool, phpMyAdmin, which helps handle the administration of MySQL. If you have ever dealt with MySQL and its initially intimidating command line interface, you will immediately appreciate how phpMyAdmin helps with creating databases and tables and modifying data within them. Plus, familiarizing yourself with phpMyAdmin may come in handy as many web hosts restrict access to the command line for security reasons.
How to Use WampServer
Go to the WampServer homepage and download the package that is applicable for your local machine. The current version available is 2.2E. The application is constantly updated, so plan on checking in periodically to ensure you have access to the latest version available.
Once you have installed the package, you should see the WampServer icon in the Windows system tray next to the clock display. You may need to click the “show hidden icons” up arrow to see it.
The WampServer menu has links to several related pages and folders.
The uppermost and most important page is Localhost. Clicking Localhost brings up your browser and displays the WampServer menu page which confirms the server is functioning correctly. You will see the versions of all applications and extensions that are installed under the Server Configuration heading.
Under tools are links to the
phpinfo() function which, when clicked, will display all of the information related to your particular installation and configuration. Below that you will find a link to the above mentioned phpMyAdmin.
Under the Your Projects heading is a display of the project folders you are working on. Each of your projects should be within its own folder. Your project folders are copied into the
www subfolder within the
Running a PHP Script
When clicked, all PHP files and scripts placed in the
www folder will be processed by the Apache server where any PHP code will be parsed and processed by the PHP application. It’s almost magical how a PHP script can establish a database connection, execute a query against the database, and dynamically return the results to the client. Depending on the nature of your script, the results can be returned as HTML back to the client browser for display.
During development, when PHP encounters any code errors (and trust me, as a newbie you will encounter many errors), PHP has the ability to display error messages that are great clues to finding the source of the error. The process of error checking and solution finding is part of the learning curve of any programming, and reason enough to set-up a local development server. Without it, one would go nuts having to upload each file revision using FTP to the web server.
In closing, server-side programming without doubt has its challenges. But now you are aware that setting up a development server using WampServer can save a lot of time and frustration and provide you with the means to safely develop your next killer application on your local machine.
Image via Fotolia
Matt Bragg lives in Southern California, developing PHP/MySQL security applications used in the thoroughbred horse racing industry. He began studying Fortran many years ago and is currently focused on furthering his knowledge of PHP and developing WordPress sites for music artists. Matt splits his time coding and working as a professional musician. You can follow him on Twitter @braggm.