I am working on a social network type project in OO PHP and I do not want to use an existing framework. The main point of doing this project is to help me learn about more stuff.
This question is more about dependency injection.
Let's say I have these classes:
core class - some core methods to do stuff in the app
config class - loads site config stuff
database class - connects to mysql and does all database related stuff
logger class - used to log errors and debug info
captcha class - for captcha on forms
session class - initiates a session start and adds, removes, gets session variables to use in the app
cache class - similar to session class but for caches items (files cache, memcache, apc cache. I may even add my session stuff to this class someday since all these cache's can use the same type of methods)
All the classes above will most likely be used on every page load in my app (I probably missed some more classes that will be added later on)
Now in addition to the above classes which will need to be injected into most other classes, I will have many many more classes. I will have a secion called modules which will have stuff like...
account class - creates new users, authenticates users, logs users in and out of the app, update user settings, and much more.
users class - shows users profiles, shows users online, new users, all stuff to show users of the site
forums class - will be for the forums section
blogs class - for the blogs section
photos class - all photo related stuff
comments class - handles comments for photos and profiles
There will be many more of these type of classes for different sections of the site.
This second set of classes listed above for sections will most likely require most of the classes from the first set to be injected into them.
So should I use a registry to store the objects from the first set of classes and just inject the registry into all the class objects in the second set of classes?
Or should I use the constructor to load them? In this example there would be like 7 objects to inject into the other classes, that seems like a lot. Am I going about this wrong?
---EDIT---
I am aware of the singleton pattern but I don't think it is my best option here
---EDIT 2---
As some have mention, needing to pass in as much as 7 objects does seem like a LOT and that is why I am looking for suggestions. Luckily for me this project is at the beginning stages so now is the time for changes to the structure.
An example would be a class in my forums section. The forums class would need access to session data, possible cached data, the configs object, database object. AM I going about this the wrong way?