Sunday, October 28, 2007

Chapter 2: Planning Your Project


Overview

Once you have an idea for a website, you want it to be up and running as soon as possible. However, for a website to be successful, it has to be well planned. If you want to take chances by using a shotgun method of building a large-scale project, it will more than likely fail.

For example, if I came up with an idea to sell funnel cakes on the Internet and offer free delivery worldwide without researching and planning this kind of idea, I would definitely be in for a big surprise. Say I built the website from this idea without researching how to actually ship a funnel cake to a person without it becoming rotten-not only would my customers be irritated at me, but I would lose a lot of money. I think you can figure out where I am going with this: Planning is essential.

Furthermore, investing some time for planning in the early stages of a project can save a lot of time on the back end. In this chapter, I walk you through the methods used to plan a full-scale project. It is well worth the time and effort to do this right.


Getting the Most from Your Idea

When an idea for a website pops into your head or someone brings you an idea and wants you to design a website, the possibilities may seem endless. You should allow your mind to wander into as many depths of creative thinking as you can. Creative thinking is the key to a great start with the website.

Do not approach your website idea with a single focus or a narrow mind. You should take into account your development skills, budget, hardware, target audience, and the time involved to implement your idea. When you have considered all of these variables, the idea turns into a project.

Usually, when I come up with an idea, I try to make every effort to mull over the idea before taking it seriously. If I can keep my mind focused on this idea for more than a day or two, then I begin the next phase, brainstorming.

Let's look at an example: Around Christmas time a few years ago, I decided I would try to get my wife a dog. I looked up all of the phone numbers for dog kennels or veterinarians in our local phone directory. Unfortunately, the phone directory was not organized very well, so I became frustrated. I had the impression that the phone directory had a website, so I called the publisher and asked if they had a website where a person could search for phone numbers. The reply I received was not too promising. The previous webmaster had moved on to other things, and the website was built with Macromedia Flash and was no longer updated because nobody had the source files. Unfortunately, this website was two years old, and most of the information was incorrect anyway.

After I hung up the phone from talking to the publisher of the phone directory, I started thinking. I came up with the idea to use PHP and MySQL to create a dynamic website that would allow users to search for the phone numbers they desired as well as a method for the company that owns the phone directory to allow people in their office to easily manage and maintain it through web-based administration pages. After thinking for a few more days of how useful it would be to have a website such as this, I started to brainstorm some details for this idea.

Brainstorming Details for an Idea

When you start brainstorming details for an idea, you should consider every variable possible for all types of audiences. Think of every detail you can for your project and then write them down. It does not matter how crazy the details you think of for your idea, you should make a record of them. You will start the process of eliminating the bad ideas later; for now, just write them down while they are still fresh in your head. Try to give this phase of the process at least a day or two to get your initial ideas documented; when it is time to move on, you will start the process of elimination.

Expanding on the example I started in the previous section, the following list contains the ideas I came up with for the user-accessible pages:

  • Phone number listings

    • Which data fields need to be collected?

    • Business name

    • Voice phone number

    • Fax number

    • E-mail address

    • Website address

    • Office hours

    • Other information (products for sale, special contact information, and so on)

  • Phone directory index with categories for phone numbers to be assigned to based on their genre

    • Yahoo-style link index?

    • Subcategories under parent category

    • How many subcategories before displaying a More link?

    • Only show one subcategory depth to the main category?

    • How to sort the subcategories under each parent category: alphabetical, sort order, or number of listings assigned to the category?

    • Drop-down menu category list?

    • Which method to sort the parent categories: alphabetical, sort order, or number of listings assigned to a category?

    • Search engine

    • Which fields to search?

    • Advanced search options

    • Limit search result options

    • Custom telephone list

    • Allow users to create a custom telephone list via the MySQL database

    • Use cookies or sessions?

    • Allow users to print their custom telephone lists with a printer-friendly page

This example shows a small portion of my brainstorming ideas for the project. The list could go on for quite awhile. As you can see, I simply started writing down my ideas and kept them flowing. Even though they may not be fully suited to the project and may not be used, I still wrote them down.

After I have a complete list of ideas on paper, so to speak, I start researching them to every extent possible.

Researching Concepts

Once you have your idea and brainstorming phases completed, you can start researching the details. Researching can be simple, or it can be hair pulling. As valuable as the Internet is these days, it is still difficult to find the information you need. PHP has only been around for a few years. This makes researching ideas for using a PHP-based development platform somewhat complicated. However, there are still some great places to find the information you need. Here are some I use every day:

Google search engine A priceless asset for finding virtually anything you need on the Internet. See http://www.google.com/.

Google Groups Millions of newsgroup messages have been indexed in the Google Groups section for nearly all of the newsgroups in existence. Google Groups is a great source for finding questions and answers from newsgroups for nearly the last five to 10 years. See groups.google.com.

PHP manual The PHP manual, although not always the most comprehensive material for everyone, has some great information that may directly involve your project. Also, the online version of the manual and the Windows Help (CFM) version also have helpful user comments. See the "Documentation" section at http://www.php.net/.

PHP information sites Another great source of PHP information are the sites that fellow developers have set up for you to find tutorials, code examples, and user forums. Here are a few:

PHP Freaks.com This is my personal site, and nearly 15,000 visitors a day interact to help each other with various PHP topics. The site is complete with forums, tutorials, code examples, live chat, and more. See http://www.phpfreaks.com/.

OxyScripts.com A fellow PHP developer has his own site with a small community similar to PHP Freaks.com. See http://www.oxyscripts.com/.

Zend Technologies This is another great source for tutorials, tips, and much more. Zend Technologies is also the home of Zend PHP accelerators and other add-on software. See http://www.zend.com/.

HotScripts.com This is a great script directory with links to scripts and tutorials. See http://www.hotscripts.com/.

This list, although not complete, will get you started finding the information you need.

When you start researching your ideas, try to find something similar to what you have in mind. It does not really matter if what you find is written in PHP because if it is on the Web and it is dynamic, you can do it with PHP. For example, it is easy to reproduce a site written in Perl or Active Server Pages (ASP) once you learn the ropes.

For the project example I have already given you in this chapter, I had to research some of the ideas, such as how to build a PHP and MySQL search engine, how to use cookies with PHP, and so on. Through my research findings, I determined the best approaches for my project, and I moved into the next phase: planning and information gathering. Keep in mind that as the development phase progresses, you will more than likely have to research additional problems, so do not overdo the initial research. Hold off on researching every intricate detail until the coding portion.


Planning and Information Gathering

Have you ever heard of the concept known as the "peanut butter and jelly of programming?" Basically, it does not matter whether you put on the peanut butter or the jelly first-you still get the same result: a peanut butter and jelly sandwich. Working with that metaphor, you have already found the bread (the idea and the details) required to make the sandwich. Now you need to spread on the peanut butter and jelly-in no certain order. I prefer to put the peanut butter (layout and design) on first, instead of the jelly (the coding portion) so that is where you will head right now.

Planning a Website Layout, Sections, and Features

Now that you have an idea and some details, and you have done some research, it is time to start a layout. Some people prefer to do the coding first and the layout later, but I can assure you from experience, it is much more practical to do the layout first. When you have something visual to look at during development, you can see how your code fits the layout and reduce your development time dramatically. Once again, this is the "peanut butter and jelly of programming."

When you plan your layout for a project, try to determine the best way to use the layout space you have. If you are going to advertise on your project's website, consider where you want the advertising to "plug in" without distracting the readers from the reason they are at your site. Try to make your layout as smooth and clean as possible.

When I developed the project mentioned in this chapter, I knew that the company wanted to advertise on their website, and I also knew that I needed to provide an easy navigation system of links on the left side of the website. From there, I started to build the layout. I tried every means possible to avoid using frames and stuck to using HTML tables and cells to build the layout. Once I built the layout files, I started to code the website into the layout.

For the sections of the project's website, I started using my brainstorming process to see what would actually fit the best, and I looked for logical ways to put them all together. I knew that I would create the directory index with all the categories listed, the custom telephone list feature, and the administration functions. Using the same layout files for the "shell" of the website, I modified them accordingly to navigate through all of the sections I built. If you plan smartly, you can modify any section of your website easily throughout the development. Chapter 4, "Building a Website Template with PHP," covers how to build a reusable website template and covers more layout concepts.

Planning a MySQL Database

When it's time for you to begin planning a database, you need to have the basic ideas for what you are going to do. A database consists of tables and columns (or fields). A table is the section, and the columns or fields are the subsections of the table. For example, a table called news is a main section of the database, and the columns or fields in the news section-such as title, date, author, and article-are the subsections.

When it is time to plan a MySQL database for your project, you should follow the ideas you came up with in the brainstorming phase. Let's expand some more on the example for this chapter; I will give you an example of the database layout I used for the phone numbers section of the project.

First, I decided which tables to use. For this example, I created a table called phonebook_listings. I try to use a prefix for all of my tables that matches their relevance. For example, this table will be prefixed with phonebook_. This also allows me to use the database for other sections that I create later, for example, news_articles and news_categories for a news section of my website. Now I know that I have a phonebook section and a news section, and I know what tables belong to what section. This is only a personal preference, but it may help you keep your database looking tidy.

Now that I have chosen a table name, I need to create columns. I began thinking of what I would need for each phone number listing, and I came up with a list similar to this:

  • Company name or person's name

  • Category ID (comes from a separate table)

  • Primary phone number

  • Secondary phone number

  • Fax number

  • Address

  • Website address

  • E-mail address

  • Business hours

  • Other information

This list covers all of the information I will need to gather about each phone number listing in my database. With my basic list, I will create "MySQL-friendly" names for each of the columns; when it is time to design the database, I will refer back to this plan.

Along with planning the sections, you should consider a table layout such as the example I just gave you for each of the sections where you desire to use MySQL. Try to think of each element for the section you are going to use and make a list of them. The next chapter covers in depth how to create and administrate the MySQL databases.

Planning for a Target Audience

Another important planning consideration is the target audience. You should decide at an early stage for whom you want your website to be built. I built my PHP Freaks.com website specifically for web developers who desired a more advanced application of their skills. Based on that information, I decided how to create my layout and plan the sections for the site.

Your website may have a wide or narrow target audience, depending on what you are building. A website such as Google is built for almost anyone to search for information, whereas a site such as PayPal is built for people wanting to transfer money between other PayPal members. For the phone book example, the target audience is anyone who needs to look up a phone number. That means the site should be easy to use. Every site needs to be planned, laid out, and developed accordingly for your target audience. You should make an attempt to eliminate anything that is not applicable to your target audience.

Setting Up the Project Logistics

Depending on the scale of your project, you may need to build a team to compensate for the logistics required. Whether your team consists of a graphic artist, additional developers, server managers, team coordinators, and so on, you must carefully consider each of these roles. You know that you will definitely need a developer, but what about the other people?

PHP Developers

If you decide you need a PHP developer other than yourself, you are in luck. Good PHP developers are spawning all over at a rapid pace. Because PHP is evolving quickly, you should have no problem putting together a team of developers for your project. A good place to look for people hunting for work is usually in message boards or web-based forums. My PHP Freaks.com website has a separate forums system with a subforum for freelance developers. Usually, you can post your request in these forums, and someone will reply shortly if interested. You can visit the PHP Freaks.com forums at www.phpfreaks.com/forums and click the PHP Freelancing forum.

Currently, the going rate for an experienced PHP developer ranges from $25 to $75 per hour, depending on the skills required. However, if you are compiling a project team, the developer may be interested in a percentage of the earnings. If you are putting together a freeware project, the developer may be interested in developing just for the recognition. Many developers have their own opinions on projects; some do not care about the money and only develop as a hobby. Once again, this shows the dynamics involved with this type of skill and expertise.

Graphic Artists

Graphic artists, in my experience, are the most difficult to find. Sometimes you will get lucky and find someone experienced enough with Adobe Photoshop, and they may only be interested in getting their name in the credits for your project or adding another page into their portfolio. However, you may also find money-hungry graphic artists who are only seeking a quick way to make cash. Regardless, you will need to find someone who will fulfill your requirements and be readily available to accomplish the project's demands. Keep in mind that most projects you develop will require some sort of alterations and graphic elements throughout the stages of development. A perfect example of this is the need for icons, bullets, and web banners; in my experience, these are items people think of as the project progresses. When you negotiate with your graphic artist, try to keep something open in your agreement for additional work beyond the initial layouts. If you need to hire a graphic artist, you can easily find one at http://www.elance.com/.

Server Administrators

Server administrators are becoming fairly easy to find these days, depending on the level of skill and trust you desire. Linux, the preferred operating system for web servers, is growing rapidly in popularity. A Linux administrator should not be too hard to find if you keep your eyes open. Try to keep in mind when searching for a good Linux administrator that you will need someone who is proficient in all aspects of web server administration. This means you not only need someone who knows how to configure PHP for your server but who can also handle a wide range of duties. The following is a short list of technologies that I would want a Linux administrator to have familiarity with:

Apache web server Of course, in Linux, I prefer to use Apache because of its speed and reliability, so I would require someone who knows how to install and maintain Apache. A few important skills to look for specifically are the ability to manage Secure Sockets Layer (SSL) connections, virtual hosts, and security.

PHP PHP is not always a plug-and-play operation. You will need someone who knows how to configure PHP, edit the configuration files, compile additional modules, and, most important, ensure security is set properly. PHP could potentially be any server's worse security nightmare if not configured properly, so make sure your server administrator really knows what they are doing!

MySQL database server This is fairly easy to configure and maintain. You should still consider someone who has experience in this area. Even though you may easily manage MySQL by using some great third-party applications, knowledge of the MySQL configuration files, security, and options should still be an important consideration.

FTP server Using the File Transfer Protocol (FTP) to update your files on the server is an absolute requirement. Once again, someone who knows how to configure FTP to be secure and prevent access to root file systems is a definite consideration. FTP, like most applications that run on your server, could potentially be dangerous if not configured properly.

Domain Name Server (DNS) DNS allows you to translate a domain name into the server's address on the Internet. DNS management involves a large learning curve, and DNS server administration is something that should not be taken lightly. A few different types of DNS servers are available, but for Linux, I prefer to use the BIND package.

E-mail server Although there are more than a few handfuls of e-mail servers out there, the most popular ones are Sendmail (default mail server on Linux, http://www.sendmail.org/) and Qmail (http://www.qmail.org/) for Linux servers. Regardless of which one you choose, security should be the number-one issue.

An incorrectly configured e-mail server could damage your communication requirements involved in any website. For example, if your e-mail server is an open relay, some companies or individuals could use your server to relay their spam, or bulk mail, through your server. After a few spam reports to selected agencies, your server could be blacklisted, and those using spam mail filters might block important e-mails coming from your server, thus reducing your communication capabilities and, in turn, reducing your business capabilities.

The bottom line is that e-mail is important; find someone who knows exactly what they are doing!

Updates and security All but the least of your worries is the security and updates required to maintain your servers. Someone who knows how to configure a firewall, disable anonymous access, harness root access, and perform required updates on the core operating system and the applications involved is essential to the operation of your server.

Linux servers are known for being secure because people make every attempt to find exploits in the software; when an exploit is found, it is usually reported to the Linux developers, and patches are released within days.

Some Linux operating systems will notify your server administrator when an update is required. You will need a server administrator who will stay up-to-date and ensure that you have all of the latest versions and patches installed on your system.

Miscellaneous Although most flavors of Linux will manage themselves through smart planning and implementation of the operating system, they will always need some sort of management to ensure things are running smoothly. This task may be minimal, depending on the activity on your server, or it could be time consuming. Either way, you would be able to sleep well at night knowing that someone is monitoring your systems to ensure that maximum uptime is achieved.

The bottom line to choosing the right server administrator is to find someone you can trust. You will find that not every experienced Linux administrator has a certification. Personally, I would hire someone regardless of a certification, based upon their skills and experience. Linux certifications are not given out as frequently as the Microsoft certifications, so the certified administrators are hard to find.

If you are determined to use your own servers, I think the best place to find a person who can fit all of the requirements for the previous list is someone who has run or worked at a web hosting company. These people will more than likely have experience in all of the requirements for a good server administrator. Most of the requirements may be learned fairly easily through documentation on the Web, but it requires some talent and ambition to become competent at these tasks. If you need assistance with learning Linux, check out http://www.linuxforum.com/.

Project Managers/Team Coordinators

Depending on how many people you have on your project team, you may need a project manager/team coordinator to keep things moving in the right direction. A project manager is the person who will maintain a list of tasks involved, build timelines, coordinate between the project team members, and compile all of the elements involved with the project into phases.

To be the most effective, your project manager should not perform any other task besides project management. However, this may not be practical, so you may find that one person will perform many different elements. Besides, the fewer people you have on the project, the easier the project could be to manage, so you will have to take this into consideration when you decide who to involve and what positions to fill.

What's Best for You?

Not every project requires a large team to be successful. You have to alter the requirements depending on the scale and budget of your project. For example, most of the projects I work on, I go solo and fill most of the positions myself. I find it easier to work by myself than wait around for other people to catch up to me. I find it difficult and frustrating to wait for another developer to get back from vacation or to find time in their busy schedules to work on the sections that I need before I can move on to the next phase. That is one disadvantage of building a team of people-the actual time loss involved in waiting for other people to complete their portions of work.

Regardless, if you have a strict timeline, what happens if someone does not complete their work at the expected deadline? What happens if someone backs out on your project, and you have to start over? For instance, consider the amount of time lost to figure out what happened and to find a replacement to do that person's work while the rest of the team has to wait. If you are on a critical timeline, this could be devastating to your project. However, when things work smoothly, everyone benefits from a team effort.

When I was asked to develop the phone book project I discussed earlier in this chapter, I developed all aspects of the project on my own. This was a good learning experience because I got to see what it takes to build a project like this and I had a taste of what each of the positions on a team would go through. Based on that experience, I learned to better manage a team on later projects.


Considering the Hardware Requirements

Every project has different needs for hardware requirements. Surprisingly, hardware considerations are the least of your problems. PHP and MySQL do not require massive top-of-the-line hardware systems to run efficiently. To be honest, I have found that most web servers will run smoothly on the minimum system requirements to run Linux. Because Linux utilizes your hardware and processor much differently than Windows-based systems, you are not required to have massive amounts of hardware to run a Linux server that does not use a graphical interface.

Another great advantage of running a dedicated server is the fact that you do not need hyped-up sound and video cards. In fact, you can remove the sound card completely and step down to a standard Video Graphics Adapter (VGA) video card that would cost you around $20.

Let's look at a standard system required for a web server.

  • Computer case

  • Motherboard

  • Central Processing Unit (CPU)

  • Random Access Memory (RAM)

  • Hard drive

  • CD-ROM (for installation of the operating system)

  • Memory (RAM)

  • Video card (basic)

  • Network adapter

With this system, you can probably find a nice motherboard that has the integrated network and video adapters. You only need the CD-ROM for installation; otherwise, you can remove it if you like.

To consider the size of the hardware you require to run your websites from, you need to know more about your project. One of my web servers runs from an AMD Athlon 650MHZ processor with 512MB of RAM and a single 40GB hard drive. This is probably the smallest computer I would use for a project, but it efficiently runs 25 websites, an e-mail server, a DNS server, and an FTP server, along with some other applications I use. During the first few months of running the phone book project, we utilized this server with high traffic loads with no problems.

It really does not matter about the size of the hardware. If you are building a website that will be viewed by 10,000 or 100,000 users per day and that uses PHP and MySQL, you do not need a massive server that costs a lot of money. Even though I say this, many people will still try to purchase as top-of-the-line servers as they can. This is not a bad idea because once you move through the steps involved in configuring a new server, I am sure you would not want to move to another server anytime soon.

The bottom line with hardware requirements is to find something you can afford without breaking your budget. If you can afford a top-of-the-line server, then go for it because as you move on to new projects, you will probably be able to share the same server with multiple websites. However, if you do not want to break the bank, purchase something a little bit slower but expandable in memory size. You can always attempt to upgrade later.

What's Next?

This chapter covered quite a bit of information about planning your project. It is up to you to choose how to plan, design, and implement your project. This chapter was written to aid and to share with you the methods I use to develop a project. The chapter covered many areas such as thinking of an idea, brainstorming, planning features and sections, planning your database, building your team, and considering hardware requirements.

In Chapter 3, "Building a Database Schema with MySQL," you will start working with MySQL. You will learn about using different column types, creating a database, creating tables, creating columns, and working with some excellent third-party software to manage your MySQL databases.

No comments yet