Jump to content

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/87443-messaging-between-objects/
Share on other sites

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.

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.