chadjohnson Posted January 23, 2008 Share Posted January 23, 2008 Suppose we're using an object-oriented framework for our web site. We're obviously going to have a few common objects used throughout the framework, such as User and DB (or just a DB connection link). How would you go about making these objects available inside of the member functions of your classes? Would you encapsulate them some common object, like "Settings" or "Context"? Would you make these objects available inside member functions via "global $VARIABLE_NAME;"? Pass them individually or the Settings/Context object as a whole as a constructor parameter for every object in your framework? Surely someone else has faced this problem before... Quote Link to comment https://forums.phpfreaks.com/topic/87443-messaging-between-objects/ Share on other sites More sharing options...
Liquid Fire Posted January 24, 2008 Share Posted January 24, 2008 I have a base class the all other class extends from directly or indirectly in my custom framework that hold instances of my database class, configuration class, url helper class, and anything else any class might need. Oh, and all those classes use have singleton capability. Quote Link to comment https://forums.phpfreaks.com/topic/87443-messaging-between-objects/#findComment-447762 Share on other sites More sharing options...
chadjohnson Posted February 17, 2008 Author Share Posted February 17, 2008 Just FYI for anyone out there--I went with this: http://www.patternsforphp.com/wiki/Registry. Thanks for your idea! Quote Link to comment https://forums.phpfreaks.com/topic/87443-messaging-between-objects/#findComment-468577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.