I have asked a few question lately about the use of the singleton and registry patterns but here is a new question I have.
Let's say I have 3 main class object in PHP that I need to have access to inside 20 other class files and sitewide.
- Database object
- Cache object
- Core object
I then can use a Registry pattern to store all 3 of these object into 1 registry object which we will call the "Registry object"
The registry class will have a singleton method so that we can make sure we only call the Registry object 1 time.
So far all is good, here is where I need your advice. All the 20 other classes now have access to the 3 main objects I mention above. But inside those 3 object above, is it ok to have them include the registry object too? Because they will need access to each other as well, or should I just reference a singleton method for the database, cache, and core object inside of each of these 3? This may be a dumb question and I am probably just a little confused because the singleton from the registry object probably makes it ok to include the reistry inside the objects that make up the registry?