phpHoo, Part I | WebReference

phpHoo, Part I

phpHoo, Part I

Abstract

Jonathan Eisenzopf has done a great job showing how easy it can be to create a Yahoo like directory using Perl. perlHoo's elegant design makes for a very useful Web application that adds significant value to a Web site, while maintaining a high degree of simplicity and ease of maintenance.

Laurence Gold has shown us how easy it can be to create the same simplicity and elegance using ASP technology. Although the end results (perlHoo and Yahasp) are models of simplicity, they both have made design decisions that, ultimately, lead to the failure of both of these programs as viable long-term solution to the "Yahoo like directory" goal. This tutorial will address and solve these limitations by using PHP and a relational database. (MySQL). In part I of this tutorial, we'll start out with the basics of using MySQL with PHP, and create a program with the same functionality found in part II of the perlHoo tutorial. We'll also be adding a few new features.

Designing phpHoo

A program's initial design is probably the most critical phase of programming. When you sit down to write a program, you must take the time to design it correctly from the very beginning. Take a look at the design decisions of perlHoo and Yahasp.

The design criteria was as follows:

  1. Organizes information hierarchically
  2. Contains information about resources on the Internet
  3. Allows users to suggest new resources
  4. Allows editors to modify the directory content
  5. Is simple to maintain
  6. Takes less than 1 week to develop
  7. Exports and imports directory content from/to multiple sources
The perlHoo initial design solution to accomplish goal #1 was to create a directory and file structure, where each Category became a directory on the file system, and links were stored in text files. This solution is not scalable and is not feasible for sites with limited resources.
  1. Your provider may place a cap on the number of files you are allowed to have. (Quotas) The number of files and directories your programs require now become very important.
  2. Regardless of how the program is written or what language you use, file system access will always be the single most resource intensive operation in your program. Your program performance will be directly proportional to the number of file system calls it makes. The more files accessed by the program, the slower it gets. Guaranteed. Creating a program designed around file system calls is a recipe for disaster.
  3. The more useful your directory becomes (more categories with more links), the slower it will be. (More files and directories to search through)
And that is the magic word, isn't it? Search. Program design becomes even more important when you consider the ultimate goal of your program - to eventually implement some means of searching this directory for the information you want. Face it, Yahoo's site would be virtually useless without the ability to search it. Using flat-text files and dozens of directories are no longer viable options when you consider this goal.

phpHoo Download source | Try It
phpHoo is a PHP version of PerlHoo. It is a bit more advanced and requires the MySQL database.

http://www.internet.com

Produced by Jonathan Eisenzopf and
Created: July 20, 1999
Revised: July 20, 1999

URL: http://www.webreference.com/perl/xhoo/php1/