Now: Tutorial for Web and Software Design > PHP > PHP Basic > PHP Content
> Simplify PHP Development with WASP [Bookmark it]
Simplify PHP Development with WASP

Simplify PHP Development with WASP


01/19/2006

WASP (Web Application Structure for PHP) is a three-tier framework built on PHP 5. Lately, more software engineers are moving from cumbersome "enterprise" languages such as Java and C# to languages such as Python and Ruby and PHP. With version 5, PHP has finally reached the point where these developers can feel at home in what used to be considered a hacker's language. By demonstrating that it is possible to create and use complicated, "enterprise-class" frameworks effectively in PHP 5, WASP will help more developers make the switch.

WASP's initial basis is in the ideas mentioned in the article "Three-Tier Development with PHP 5." Since then, it has come a long way toward bridging the gap between PHP frameworks and other, traditionally more accepted three-tier tools. PangoMedia has put it to large-scale use in several production applications.

This article demonstrates how to build a small database-driven application: a simple task-list web application. This example is short; however, it demonstrates most of the powerful features that WASP has to offer.

The code in this article uses WASP 1.1. Some familiarity with PHP 5 syntax is helpful, but not necessary. For more information on the methods and classes used in this tutorial, see the WASP API documentation. For additional reference, the following resources may be helpful:

  • PHP Manual
  • "Classes and Objects in PHP 5"
  • "DB_DataObject reference"
  • "HTML_Template_Flexy reference"
  • Phing reference

Installation and Configuration

Download and install the latest version of WASP via the PEAR package manager. For detailed instructions, see the WASP Installation and Configuration guide.

Create a WASP project by running the command:

phing -buildfile PEAR_DIR/lib/php/data/WASP/build.xml wasp-project

where PEAR_DIR is the installed location of your PEAR classes. You can find out where this directory is by running:

$ pear config-get php_dir

If all is well, you will see:

Buildfile: /usr/local/php5/lib/php/data/WASP/build.xml

WASP > wasp-project:

Directory to create project in  >

Enter the fully qualified path where your new WASP project will be created. This will create the directory and copy over the build.xml and build.properties files.

For the purposes of this example, I've used /Users/brianfioca/Development/projects/Todo.

Make sure the directory you choose is accessible from within your web server's root.

You should now have a directory called Todo that looks like this:

|_Todo

   |_build.xml

   |_build.properties

WASP uses Phing and the build.properties file to manage its configuration. When you create your application, the Phing tool reads your build.properties and builds the correct configuration files for your project.

Here is a build.properties file that has default values for this tutorial.

build.properties
###################

# FILE: build.properties

# DESC: wasp project configuration properties file

#

# The properties below are used to configure your wasp application.

# Set these properties to customize your wasp install.

#

# run phing config to regenerate the configuration when these are changed.

##

# The name of the application

app.name=       Todo

# Toggle Debug output 

debug.flag=     True

# Toggle for email of error messages

email.flag=     False 

session.flag=  True

# URL of the database for this application

database.url=   mysql://user:pass@localhost/todo

      

# Directory where pear packages are installed

pear.dir=       /usr/local/php5/lib/php

In the configuration, the app.name property is Todo, which will be the name of the application as well as the name of the root directory (located off of the app.dir directory or the wasp directory, if not specified) of all modules, chunks, and templates that the build tool will create.

The app.dir property is the directory where the application will reside within your web root. For this example, I've set the app.dir to /var/www. This is the directory that the Apache HTTP server considers its root directory. Change this directory to match your particular web server configuration. When the application is installed, it'll reside in /var/www/Todo.

Set the pear.dir property to the location of your PEAR classes: the directory that contains DB/DataObject and HTML/Template/Flexy. As I mentioned before, you can also find the location of this directory by running:

$ pear config-get php_dir

Set the database.url property to the URL of the database that your project will use. This example assumes you will be creating a database called todo on the MySQL instance on the local host.

If at any point you wish to regenerate the configuration, run the command:

$ phing config
Building Tag Clouds in Perl and PHP

Essential Reading

Building Tag Clouds in Perl and PHP
By JimBumgardner

Tag clouds are everywhere on the web these days. First popularized by the web sites Flickr, Technorati, and del.icio.us, these amorphous clumps of words now appear on a slew of web sites as visual evidence of their membership in the elite corps of "Web 2.0." This PDF analyzes what is and isn't a tag cloud, offers design tips for using them effectively, and then goes on to show how to collect tags and display them in the tag cloud format. Scripts are provided in Perl and PHP.

Yes, some have said tag clouds are a fad. But as you will see, tag clouds, when used properly, have real merits. More importantly, the skills you learn in making your own tag clouds enable you to make other interesting kinds of interfaces that will outlast the mercurial fads of this year or the next.


Read Online--Safari
Search this book on Safari:
 

Code Fragments only

[1] [2] [3] [4] [5] Next

[Bookmark][Print] [Close][To Top]
  • Prev Article-PHP:

  • Next Article-PHP:
  • Related Materias
    Scaling Dynamic Websites w
    Important Notice for Apach
    Custom-Compiling Apache an
    Apaches eXtended Server Si
    Simplify Your Life with Ap
    Multiuser Subversion
    Single-User Subversion
    Industrial-Strength Webcas
    Monitoring Apache Page-Loa
    Managing Sessions and Stat
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial