PHP
  Home arrow PHP arrow Page 3 - 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 - What do the "core files" do?
    ( Page 3 of 11 )

    Let's go take a look at these files now.  If there are any I don't cover today, we'll be going over them in a future article.

    fbx_Circuits.php

    Included by fbx_Fusebox3.0_PHP4.1.x.php (see below), fbx_Circuits.php is where the circuits of our Fusebox are defined.  This is the place where values are set that determine the structure of the app.  A typical fbx_Circuits (and the one you downloaded) looks like this:

    <?

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

    ?>

    Don't worry - we'll be adding circuits to this code soon enough.

    fbx_Fusebox3.0_PHP4.1.x.php (or fbx_Fusebox3.0_PHP4.0.6.php)

    This is the "engine" of the Fusebox application - the file that makes it all possible.  It does the following things:

    1. Includes fbx_Circuits.php, where the circuits array is populated with your application's circuit definitions.  The circuit definitions in fbx_Circuits.php map your site's folder structure to a central circuits structure.

    2. Creates a reverse-lookup of the directory structure you defined in fbx_Circuits.php.

    3. Includes fbx_Settings.php, where default values are set for your application.

    4. Receives the fuseaction and circuit variables, which control what content is displayed in your application.

    5. Executes the fuseaction in the correct circuit's fbx_Switch file.

    6. Includes fbx_Layouts.php, where you can customize the look and feel of your application.

    You'll be happy to know that this file should not be modified in any way, and can function as the heart of your web application right out of the box, so to speak.  You should understand the full functionality behind this key file, but this is by no means required since editing the file's source code could make your application incompliant with the Fusebox 3 specification, defeating the whole purpose of using the methodology in the first place!

    fbx_Switch.php

    This file consists of a switch/case statement that tells the application which files to include.  Here's the code you see when you open it up:

    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;

    }

    Leave this file alone for now.  We'll be back to it shortly.

    fbx_Settings.php

    This is where default values are set for each circuit.  Circuits (subdirectories) each have their own versions of this file.  If they do, the variables' values in the individual circuits' fbx_Settings.php files will overwrite their default values in the root directory's fbx_Settings.php. 

    index.php - or whatever your server's default document is called.

    This is where we load the core file, or for lack of a better word engine, of the Fusebox architecture: fbx_Fusebox3.0_PHP4.1.x.php.  We'll be linking back to this file for every page request and passing it a variable called a fuseaction.  The fuseaction will give the engine the information it needs to display the circuit's content.  Note: this file can be renamed to whatever your web server uses as its default document.

    DefaultLayout.php

    This is a typical layout file, and is required in each circuit of your application.  If you were making an application with many circuits, you'd want to make sure this file is placed in each circuit's directory, along with the other core files required in each circuit.  In a future article we'll discuss the incredibly cool use of nested layouts, which are another example of the versatility and scalability of Fusebox-based architecting.

    fbx_Layouts.php

    You should have at least one fbx_layouts.php in your application, depending on which circuits require unique layouts.  This file controls the layout of each circuit or $Fusebox["layoutFile"] element.  Any circuit that has its own layout requirements should have its own fbx_Layouts.php file in its root directory.  If not, fbx_Layouts.php can be omitted and the application root's fbx_Layouts.php will take over.  Fusebox enables you to "nest" these layouts in a powerful way, but that topic is best left for another time.

    dsp_main.php

    A typical display file.  This file will be included in our main circuit.



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