PHP
  Home arrow PHP arrow Page 6 - Scratching the Surface: Getting Started with PHP Fusebox
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Scratching the Surface: Getting Started with PHP Fusebox - Picking Up Where We Left Off: Setting Up the Core Files
    ( Page 6 of 11 )

    Now that we've copied the core files into the root directory, let's go ahead and create a simple circuit app that demonstrates the basic principles behind the PHP Fusebox architecture.

    1. Open fbx_Circuits.php.  You'll see the fusedoc XML at the top, followed by the default home circuit definition:

    $Fusebox["circuits"]["home"] = "home";

    This code is identifying the $Fusebox["circuits"]["home"] nested array element as "home".  The lack of slash mark(s) in the value in quotation marks tells us this circuit is in the root directory.

    When the $Fusebox["circuits"] structure is passed, fuseaction=home.main in the URL for instance, the application will know this circuit is in the application root, and the core "engine" file, fbx_Fusebox3.0_PHP4.1.x.php, will include the application root's  fbx_Switch.php to complete the request.

    Note: Although it isn't explicitly required to create PHP Fusebox 3 web sites, you can see how all this works by opening the "engine" file we discussed earlier, fbx_Fusebox3.0_PHP4.1.x.php.  Checking under the hood of this file is advisable.  The code is well commented with in-line comments and FuseDocs.

    Ordinarily, if we were constructing a complex web application with PHP Fusebox, we'd add additional code to define more circuits in the application root's fbx_Circuits.php:

    $Fusebox["circuits"]["sectionOne"] = "home/sectionOne";

    $Fusebox["circuits"]["sectionTwo"] = "home/sectionTwo";

    There could be as many circuits as you want.  For our purposes, we'll only be working with two circuits: the "home" and "biography" circuits.  Change the code of fbx_Circuits.php to read:

    $Fusebox["circuits"]["home"] = "home";

    $Fusebox["circuits"]["biography"] = "home/bio";

    The circuit you have just defined below the "home" circuit could be accessed through either the URL or some kind of form action (POST or GET).  For our purposes, we'll be calling our circuits through simple text links.

    2. In the root directory of your application, open fbx_Switch.php.  This is where you'll define all the fuses in this, the home (or root) circuit.  Like I said before, you'll be using the switch / case statement in this file to include files based on the fuseaction passed to the application.

    The default code looks like this:

    switch($Fusebox["fuseaction"]) {

          case "main":

          case "Fusebox.defaultFuseaction":

                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;

    }

    The switch statement switch($Fusebox["fuseaction"]) receives the $Fusebox["fuseaction"] variable from the URL, a form ñ- whatever you want to use to pass it - and passes the fuseaction down through the case statements until it finds one that matches.  When a match is encountered, the matching case statement specifies which files are included.  In this situation, if the "main" fuseaction were specified, the file dsp_main.php would be included.  If no fuseaction were passed, the same file would be included because the default case statement calls the same fuse.



     
     
    >>> More PHP Articles          >>> More By Mike Britton
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT