Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 577725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:11:04+00:00 2026-05-13T14:11:04+00:00

I have asked a few question lately about the use of the singleton and

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:11:04+00:00Added an answer on May 13, 2026 at 2:11 pm

    Why don’t you just make these 3 classes static? I’m using a static database class that kind of extends PHP’s PDO class and let me use it like this:

    $sql = "SELECT * FROM table";
    foreach(DB::query($sql) as $row) {
      // do something
    }
    

    I really like this way of using static classes/functions especially for this “global” kind of stuff. Perhaps this is an option for you too?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have asked a question about manytomanyfield here which i solved but now a
I have seen this question asked here a few times, but most question didn't
I've seen this question asked a few times but I have been unable thus
I know this question has been asked here a few times before. But i
I have seen this question asked a few times but I have not seen
I asked a similar question a few weeks ago, but now the requirements have
I know this question might have been asked a few times already, but I
Several question have been asked on SO about the use of Lights in Notification
Few days ago I have asked a question about 1,2 and 3. degree connections.
I have seen this question asked a few times on SO - but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.