====== Framework SuperObject ======
//Framework SuperObject was my first attempt at a lightweight PHP framework. It is here for historical purposes, and has been replaced by [[:csf:|CodeScape Framework]]. What follows is the content of my original project page for it.//
The Framework SuperObject is [[http://www.culinarydepotinc.com|restaurant supply]] a simple, lightweight and extensible framework object I've developed initially for use at [[http://ystv.york.ac.uk/|YSTV]], however there is no reason [[http://www.great-quotes.com/quotes/author/William/Shakespeare|Shakespeare and his quotes]] cannot be used as a [[http://www.andrewflusche.com/services/virginia-reckless-driving-ticket-defense/|Virginia reckless driving]] basis for any PHP-based site.
====== Getting Framework SuperObject ======
The FSO source can be checked out from the Git repository:
git clone git://git.codescape.net/fso.git
====== Using FSO ======
// Load the FSO class
require_once('/path/to/fso.php');
// Get a reference to the FSO object
$fso =& FSO::get_instance();
// ... or ...
$fso =& get_instance();
You can then get to any loaded module by using
$fso->mymodule;
===== Loading and accessing modules =====
You can load modules in one of several ways:
// Load module 'MyModule' at $fso->mymodule
FSO::load_module('MyModule');
// Load module with arguments to the __init() method
FSO::load_module('MyModule', array('arg1', 'arg2'));
// Load module 'MyModule' at $fso->foo
FSO::load_module('MyModule', null, 'foo');
// Load module 'MyModule' from a different path
FSO::load_module('MyModule', null, null, '/path/to/module/dir');
// Or load multiple modules
FSO::load_modules(array(
array('MyModule', null, 'myalias'),
array('AnotherModule', array('init', 'args', 'are', 'fun'))
));
Modules can also be accessed in many ways:
// When loading the module
$mymodule =& FSO::load_module('MyModule');
// From the FSO object
$fso =& FSO::get_instance();
$fso->mymodule->somefunction();
// Reference the module with another variable
$mymodule =& $fso->mymodule;
// ... or ...
$mymodule =& FSO::get_module('mymodule');
You can access any module via any other module:
$mymodule->othermodule->somefunction();
Finally, if [[http://www.premierrivercruises.com/rivers/danube-river-cruise|danube river cruises]] necessary you can load a module without actually making it part of the superobject, however it will still have access to the rest of FSO via ''$this->module'':
$mymodule =& FSO::make_module('MyModule', array('some', 'args'));
You can access any module from within any other module by using ''$this->mymodule''. If you have object variables which might interfere with this, you can also access other modules with ''$this->FSO->mymodule''.
Note: overloading ''__get()'' will stop ''$this->mymodule'' and ''$mymodule->othermodule'' types of access from working. You will still be able to use ''$this->FSO->mymodule''.
===== Adding modules =====
To create a module for FSO, create a file with the same name as the class which follows this format:
if ( !class_exists('FSO') )
die('Framework SuperObject base class must be loaded to use its modules!');
class ClassName extends FSO_Module
{
public function __construct()
{
parent::__construct();
// Stuff to do when the module is initialized
}
// Module functions go here
}
Module are not completely limited to this format---extending ''FSO_Module'' is merely a convenience to get access to all other modules with ''$this->mymodule'' syntax. If you don't need this, you can opt to not extend ''FSO_Module'', and if you want remove the first two lines too.
====== Supplied Modules ======
* [[config]]
* [[db]]
* [[session]]
* [[encrypt]]