Figaro Framework

PHP + FLEX + Open Source

 

The Figaro Framework is designed to allow rapid development for PHP/FLEX developers by doing most of the develpers "data wrangling" for them.  This allow them to work on the actual logic of their application without spending all of their time writing complex SQL queries to obtain their data.

 


 

Before You Install

 

Before installing the Figaro Framwork, you need to check that your web hosting provider fulfills the necessary conditions (don't panic! most do) and that you yourself possess the required skills (don't panic! it isn't complicated). Neither of the two should be a problem, but it is wise to verify first.

 

Requirements

  • PHP 4 or 5
  • MySQL 5
  • Text Editor
  • FTP Client

 

Installation Instructions

  1. Download the latest stable release of Figaro.
  2. Un-rar the compressed file to a local directory using a tool like WinRar.
  3. Upload the Figaro folder to the root directory of your server.
  4. Open figaro/config.Settings.php and edit the database settings
  5. Start Coding!

 

Have Figaro Installed For Free!

 

If you want to use the Figaro Framework on your own site but you're worried about installing it, you can submit a request to have us install it free of charge!

Find Out More About A Free Install

 

Installing Figaro

 

Directory Structure

  • apps/
  • lib_base/
  • mods/
  • pages/
  • setup/
  • config.Postback.php
  • config.Settings.php
  • figaro_start.php
  • .htaccess

 

apps/

Out of the box applications live in this directory.

 

lib_base/

This is the heart and soul of Figaro. All of the custom built methods and functions reside in this directory.

 

mods/

Any 3rd party software lives in this directory - AMFPHP is installed by default to aid Flex developers.

 

pages/

This folder contains all of the template files and elements that Figaro uses for your site.

 

setup/

This folder contains the setup scripts to get Figaro up and running in a matter of moments.

 

config.Postback.php

A customizable file to write custom postback methods - All the same security issues with POST arrays still apply.

 

config.Settings.php

This file contains the settings for your database, filepaths, error reporting settings and template settings.

 

figaro_start.php

This file is invoked in every page served by Figaro - it loads your default database and initializes all of the Figaro methods.

 

.htaccess

This htaccess file hijacks all header requests and forces all global variables ($_GET, $_POST, etc.) into $Request. The purpose is two fold - security on all systems and clean, SEO friendly URLs.

 

Installation

Copy all of the files into the root of your webserver - keep the directory structure consitent with the diagram above.

 

Configuration

To use a default installation of Figaro open config.Settings.php and edit lines 43-36 to match your MySQL databases server settings (db_server, db_user, db_pass, db_name). Save the file and you're good to go. Now Figaro knows what is in your database. (It's not Skynet smart - the figaro_start.php script calls $Mysql->buildSchema(); which in turn informs Figaro how your db is setup)

 

Using Figaro Templates

 

In order to use Figaro's page rendering engine you must create three files:

  • A Root level page - naming convention = filename.php (this file contains all of your dynamic code)
  • A Template file - naming convention = _template.htm (this file contains persistent elements - header, footer, html start and stop, etc.)
  • A Content file - naming convention = filename.content.php (this file contains all of the html specific to that page and any pointers that need to recieve dynamic info)

 

Setting up the Root level page

  1. Create a new page in your root directory called "hello.php"
  2. Open the file and add the following code: $Page = new Page('figaro/pages/_template.htm'); //this tells Figaro what template file to use for this page.
  3. Add: $Page->defineElement($thisPage, 'figaro/pages/hello.content.htm'); //this tells figaro where the main content of the page is coming from. $thisPage is just a placeholder - it can be any name.
  4. Add: $hello = 'hello'; //this sets the variable $hello to the string hello.
  5. Add: $Page->$thisPage->addContent('RIGHTCONTENT', $hello); //this sends the variable hello to the RIGHTCONTENT pointer in your content file.
  6. Add: $Page->render(); //this invokes Figaro's page renderer.

 

Setting up the Template file

  1. Create a file called "_template.htm"
  2. Insert the standard Doctype and basic html shell stuff in this page
  3. Somewhere inbetween your body tags insert a __CONTENT__ place holder (this will be replaced by the Content file you're about to setup)
  4. This is the place to put any persitent content (navigation, copyright verbage, contentWrapper div)

 

Setting up the Content file

  1. Create a file called "hello.content.htm"
  2. Put the placeholder __RIGHTCONTENT__ anywhere in the page. Pointers like this recieve dynamic content from your Root level page.
  3. Insert anything that you want to be included in this specific page.

 

Working with Databases In Figaro

 

All of your php code (and Figaro shorthand) will be placed inside your Root level pages. Make sure you have configured your database settings on lines 43-46 in config.Settings.php.

There are two very useful ways to connect and pull information from your database without having to write a line of SQL. The two most useful are get(); and getBY();

 

Using get();

The get(); function returns all or some of the fields from the table within your database as an array. All arguments are optional and if there are no arguements then it fetches the entire table.

$Database->table_name->get($fields = array(), $conditions = null, $orderBy = null, $limit = null)

Practical Uses:

  • $Mysql->tablename->get(); will return all of the fields in the table you specify.
  • $Mysql->tablename->get('fieldname1, fieldname2'); will return only fieldname1 and fieldname2.
  • get(); can take several arguments - $Mysql->tablename->get('field1, field2, field3', 'field4 = 3', 'field5 ASC', '4'); will return field1, field2, field3 where field 4 = 3 ordering by field5 ascending and it will limit the number of items returned to 4.

 

Using getBY();

The getBY(); function returns all or some of the fields from the table within your database as an array conditionally based on the table name used. I.E. getBYfieldname('1'); would return all of the fields in the database where fieldname = 1. Figaro automatically knows what all of your fieldnames are so you automatically have access to a getBY function for each table name in your database. Proper use: $Mysql->tablename->getBYfieldname('condition');

 

Looping Thru Arrays

The foreach loop is the basis for most of your workload in Figaro.

//define your page template
$Page = new Page('path to template');
//define your content element
$Page->defineElement($thisPage, 'path to content element');

//use get to pull info from the db
$var = $Mysql->tablename->get('field1');

//loop thru the array using the names of the fields ($data['fieldname'])
foreach ($var as $row=>$data)
{
//use the .= to add each loops output to your variable otherwise only one result
$varList .= $data['field1'];
}

//send varList to your __RIGHTCOLUMN__ pointer in your content element
$Page->$thisPage->addContent('RIGHTCOLUMN', $varList);
//render the page
$Page->render();

Useful Figaro Functions

 

Part of the power of Figaro is the library of lightweight but heavy hitting functions for real world applications built into the framework.

  • debug() - this is the mother of all useful functions - it allows you to see what is actually going on with anything... just put a die(debug($Mysql->log)); in to see what your db is doing at any point in the code... die(debug($Mysql));to see how Figaro sees your database... Or die(debug($variable)); to see what a variable is doing... you can even comma seperate multiple variables.
  • truncateStr() - useful for trimming long blog posts to fit into tight spaces. Takes the arguments str, word count, and elispsis (boolean)
  • convertDate() - ever found yourself in a situation where you have to work with a MySQL timestamp instead of UNIX time? This function will return a human readable date from a timestamp. (June 12, 2007)

Free Installation

 

The Free Service We Provide

  • A copy of Figaro installed for free on your server along with all of its components.
  • Provide directory full of tutorials and sample projects
  • An email address that will allow you to ask questions about our product

 

Information We Will Need

  • An FTP login username/password to the server it will be installed on
  • A valid database login that has all rights - will be replaced once installation is finished
  • A valid email address of an end user for Figaro

 

At the end of the installation process we will have provided you with all of the tools to start coding in Figaro along with all of the current open source Flex components that we have released that work with Figaro. We will provide as much assistance as we can in helping you through your learning curve but because we're a small shop we can't make any promises.

Disclaimer

 

Because The Lawyers Said We Have To ...

 

This is a free service that we provide to the PHP community as a way to build good will and brand recognition while also learning more about how our software works in different hosting configurations. We retain the right to refuse this service to anyone for whatever reason. We really want to see our product take off, but if we decide that the subject matter of your site is inappropriate or may possibly offend our grandmothers we will politely but firmly reject your request for installation.

 

We are also not liable for anything... It's a free service and our software is open source so you install it or have us install it at your own risk.

 


Page Information

  • 1 year ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information


Update to PBwiki 2.0

An entirely new PBwiki experience, including folders and easier editing.

Convert Now for Free | Learn more