I've got some classes that I was previously developing for a personal framework but I think would make a good addition to the app that I'd like to contribute.
Registry
This is a common solution to the globals anti-pattern.
Basically, rather than keeping variables as globals and risk overwriting them, you have a singleton instance of this class created in your bootstrap file. This remembers itself so everytime you call it it knows what's been set in it's datastore.
Class code (pastebin'ed as it's fairly long)
Example usage:
PHP Code:
$registry = Registry::getInstance();
$registry->configuration = $config; // Some config array/object
unset($registry);
// later
$registry->getInstance();
var_dump($registry->configuration);
$dbAdapter = new Database($registry->configuration->database);
$registry->database = $dbAdapter;
unset($registry);
This also includes some static methods, such as a class/interface autoloader.
Configuration
This isn't the same as the other config class which appears to load options from the database.
This is a two-parter. It has an abstract base class that is extended based on the file format you want to retrieve data from.
It allows you to use constants in configuration files. However the configuration files must be placed above the document root otherwise they will be publically viewable (and since they will likely contain database data this is bad!). See below.
Abstract Class
INI File extension
Example
PHP Code:
$configuration = new Phlox_Config_Ini(APPLICATION_PATH . '/config/app.ini');
var_dump($configuration->database);
Sample INI File
Code:
[database]
adapter = 'MySQL'
params.dbname = 'phlox'
params.user = 'phlox_user'
params.password = 'password'
params.host' = 'localhost'
Files above document root
Really, all of the includes, etc. should be above the Document Root and publically accessible files (index.php, /js/, /css/) should be the only things below it. This is available on nearly all hosts (including shared hosts - all of mine have done this).
What I suggest is that we have a public directory for front-facing files.