PHP
  Home arrow PHP arrow Page 9 - 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 - Almost There!
    ( Page 9 of 11 )

    Now that both dsp_ pages are there for either circuit, the fusebox should work, right?  It will - as soon as you add the XFA you just referenced in dsp_hello_world.php to the fbx_Switch.php in /bio.  Without reference to this XFA in your fbx_Switch.php file, your PHP Fusebox application won't know what you're talking about!

    Open the fbx_Switch.php in /bio and add the line in bold.

    switch($Fusebox["fuseaction"]) {

          case "main":

          case "Fusebox.defaultFuseaction":

                include("dsp_main.php");

                break;

          case "hello_world":

                // Add this line:

    $XFA["home"] = "home.main";

                include("dsp_hello_world.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;

    }

    As soon as you do this, add an XFA link to the biography circuit in the application root's dsp_main.php, and you'll be finished with your first PHP Fusebox application!

    <h3>Home: Main Page</h3>

    This is the home page.  Click the link below to find out more about me.

    <p>

    <?

    echo "<a href=\"$PHP_SELF?fuseaction=".$XFA["biography"]."\">Biography</a>";

    ?>

    Now fire up a browser and surf to your application root.  The default fuseaction should be triggered automatically since you didn't type a fuseaction.

    Mouse over the link to go to Biography.  Notice how the URL is now a real fuseaction and not an XFA?  That's because we defined the XFA in the application root's fbx_Switch.php file.  The Fusebox knows this XFA is a call to the application root's $Fusebox["circuits"]["biography"] circuit, which you can see when you open fbx_Circuits.php in the root:

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

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

    Now click on the Biography link.  The Biography pages comes up.  Now click the Home link.  You're back home.  Continue doing this for a few hours while listening to high-energy dance music!

    If you think this might work for you, don't stop here.  There are great Fusebox-related sites all over the web.  And Fusebox isn't just for PHP - it was originally written for ColdFusion and is available for Java, as well.



     
     
    >>> 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 2 Hosted by Hostway
    Stay green...Green IT