I've been making a cms for years and just adding 'settings' for each module and including it when needed. Now that I am refactoring I want to eliminate these settings files and also give myself a way of orchestrating all the other classes that are frequently used.
Do you use a Registry pattern to fire up oft-used classes in your application?
If possible can you post the Registry you use, or link to one you use?
I'm also interested in if your Registry has any failsafe functionality does it do any type hinting, or exception throwing.
I am Googling, and finding code samples but am getting confused as some of them are pretty old now - and some of them are using & to implicitly copy objects by reference, which I didn't thing was necessary from PHP5 onwards.
I have a second question too, which I might as well add.
Whereabouts do you instantiate the Registry and assign an object in your Application?
Say you used it in this contrived example:
Does 'settings.php' just give a central place to instantiate the Registry?
include 'config.php' ;
include 'database.class.php' ;
include 'cache.class.php' ;
// get some details from config
// get data from the database
// do things with the data
// cache the results
Does database.class add itself to the Registry? or do you do that implicitly in forum.php or does it not matter.
Gawd, as soon as I post I find the ZF Registry with tests and all ...