SunQuest
 
       PHP
  Home arrow PHP arrow Page 7 - Scratching the Surface: Getting Starte...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Scratching the Surface: Getting Started with PHP Fusebox
By: Mike Britton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2002-05-29

    Table of Contents:
  • Scratching the Surface: Getting Started with PHP Fusebox
  • Step 1: Setting Up the Core Files
  • What do the "core files" do?
  • A Word on FuseDocs
  • Fusebox Naming Conventions
  • Picking Up Where We Left Off: Setting Up the Core Files
  • Using XFAs
  • Step 2: Creating the "Biography" Circuit
  • Almost There!
  • PHP-Fusebox Links
  • Fusebox Links

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Scratching the Surface: Getting Started with PHP Fusebox - Using XFAs


    (Page 7 of 11 )

    Let's say you want one screen on your web site to lead into another, like in a traditional login system where the user types his / her username and password into a text field and presses the submit button.  In Fusebox, instead of hard-coding a path to a CGI script or another PHP page in your form's "action" parameter, you simply specify an exit fuseaction, or XFA

    What's an XFA?

    PHP Fusebox filenames must begin with either dsp_, act_, url_, or qry_.  They contain exit fuseactions that are picked up in a circuit's fbx_Switch.php file.

    For example, one of your circuits' dynamically-included files will contain references collectively known as XFAs.  When called, these XFAs communicate with the switch/case statement in fbx_Switch.php, telling it to find a matching circuit (case statement), and an XFA definition inside the case statement, one that tells the application where the exit for that fuseaction is.  It helps to remember "X for exit".

    To further illustrate, let's focus again on fbx_Switch.php.  Add the following code under the initial case statements:

    $XFA["biography"] = "biography.hello_world";

    Now your switch statement should look like this:

    switch($Fusebox["fuseaction"]) {

          case "main":

          case "Fusebox.defaultFuseaction":

    // Add this line:

    $XFA["biography"] = "biography.hello_world";

                include("dsp_main.php");

                break;

          default:

                print "I received a fuseaction called <b>'" . $Fusebox["fuseaction"] . "'</b> that circuit <b>'" . $Fusebox["circuit"] . "'</b> does not have a handler for.";

                break;

    }

    This may take a while to get right in your head.  While fbx_Switch.php dynamically includes files, it also controls the flow of the application.  Think of it as a railroad switch that directs your model train by moving the switch to the correct track.  Your train signals the switch where it wants to go, and the switch moves into place to match the signal sent by the train.  What you've just done is instruct the circuit to go to the bio/ directory (or "biography" circuit if you think about it from the perspective of the application root's fbx_Circuits.php file) when passed an XFA called "biography".  The biography circuit's fbx_Switch.php will have a case statement that looks for the fuseaction "hello_world" and include the files you define for this circuit.

    But wait, we're getting ahead of ourselves.  Deeeep breath.  First, we have to understand how these XFAs are passed in the context of the application.

    An XFA or exit fuseaction called from a URL:

    <a href=\"$PHP_SELF?fuseaction=".$XFA["biography"]."\">Example Link</a>

    An XFA or exit fuseaction called from form POST:

    <form action=\"$PHP_SELF?fuseaction=".$XFA["biography"]."\" method=\"post\">

    Or a GET:

    <form action=\"$PHP_SELF\">

    <input type=\"hidden\" name=\"fuseaction\" value=\"".$XFA["biography"]."\">

    </form>

    The beauty of PHP Fusebox is in the abstraction of the file system's real structure: using XFAs, you can send the application to any circuit (directory) you want, and have it perform whatever duties you wish.  As long as the root directory's fbx_Circuits.php contains a matching circuit definition and its fbx_Switch.php contains a corresponding XFA that can tell fbx_Circuits.php where to go next, the sky's the limit!

    More PHP Articles
    More By Mike Britton


     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway