Home arrow PHP arrow Page 9 - Scratching the Surface: Getting Started with PHP Fusebox

Almost There! - PHP

Originally designed for ColdFusion, Fusebox is a methodology for designing web-applications with extensibility and ease of maintenance that is now available for PHP.

  1. Scratching the Surface: Getting Started with PHP Fusebox
  2. Step 1: Setting Up the Core Files
  3. What do the "core files" do?
  4. A Word on FuseDocs
  5. Fusebox Naming Conventions
  6. Picking Up Where We Left Off: Setting Up the Core Files
  7. Using XFAs
  8. Step 2: Creating the "Biography" Circuit
  9. Almost There!
  10. PHP-Fusebox Links
  11. Fusebox Links
By: Mike Britton
Rating: starstarstarstarstar / 8
May 29, 2002

print this article



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":



      case "hello_world":

            // Add this line:

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




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



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.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: