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

Step 2: Creating the "Biography" Circuit - 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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

You've added code that references the biography circuit, so now it's time to create it!  In your application root (the one you're calling "home" in fbx_Circuits.php), create another directory and call it bio.  This is where we're going to build the biography circuit.

Now you must copy the following PHP Fusebox core files into the bio directory (it's a subset of the same files found in your application root):

DefaultLayout.php

dsp_main.php

fbx_SaveContent.php

fbx_Settings.php

fbx_Switch.php

index.php

See, there's fbx_Switch.php again!  The biography circuit's fbx_Switch.php will include the files needed to satisfy the fuseactions passed to it, as we've already discussed.

Open the /bio directory's fbx_Switch.php.

You will see similar code to the fbx_Switch.php we already edited, in the application root:

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;

}

Keep this file open, and focus back on fbx_Switch.php in the application root.  Remember when we created an XFA for the "biography" circuit?

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;

}

Now we're going to adjust the fbx_Switch.php file in /bio to accommodate the XFA we just set up in the application root's fbx_Switch.php.  Add the code in bold to the /bio directory's fbx_Switch.php:

switch($Fusebox["fuseaction"]) {

      case "main":

      case "Fusebox.defaultFuseaction":

            include("dsp_main.php");

            break;

      case "hello_world":

            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;

}

Now open dsp_main.php in /bio and save it back down as dsp_hello_world.php. Add the following code to dsp_hello_world.php:

<h3>Biography: Hello World!</h3>

This is the place where the world can come learn about me.

<p>

<?

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

?>



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

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