Results 1 to 1 of 1
Thread: Show us your Registry?
Aug 16, 2009, 06:50 #1
- Join Date
- Oct 2006
- France, deep rural.
- 17 Post(s)
- 1 Thread(s)
Show us your Registry?
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:
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 ...