I thought on this approach, but it has some cons.. 1. PHP 5.3 is needed 2. You class acts as a SingletonContainer 3.
Derived classes are considered different 4. You are calling the constructor But it has the advantage that you just need to extend that class to have a Singleton – Eridal Aug 19 '10 at 13:59.
Remember PHP doesn't allow multiple inheritance so you must carefully choose what you base your classes on. Singleton is so easy to implement it's probably better to let each class define it. Beware also that private fields are not ported to descendant classes and therefore you can have two different fields with the same name.
First of all: if you have so much Singletons over the project then you probably mess up something on projection level Second of all: Singleton should be used there, and only there, where more that one instance of a class makes totally no sense or might cause some errors Finally: the inheritance ain't designed to reduce the amount of code.
IoC containers commonly support registering an instance against an interface. This provides your singleton behaviour as clients resolving against the interface will receive the single instance. You will also get the added advantage that you can vary the implementation of the singleton easily as it is registered against an interface.
This can be useful for production, but perhaps more so for testing. True singletons can be quite painful in test environments.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.