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 9047077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:48:51+00:00 2026-06-16T11:48:51+00:00

This is my current system for a framework that I’m making: I create an

  • 0

This is my current system for a framework that I’m making:

I create an object upon a request to access a non-existing property, that has the name of an existing class through the __get function defined in the Core class. The Core class extends every class.

So it works like this:

class Someclass extends Core
{
    public function classmethod()
    {
        $this->otherclass->method();
    }
}

This works exactly how I want it to work. However, I have no idea (after a lot of frustration) how to edit/create properties of the object, using this system.

So something like this would’t work.

$this->view->somevar = "newvalue"; // this doesn't work. 

I guess it has to do something with the __set function, but I failed to find out.

I received the following suggestions how to tackle this problem:

Dependency injection, Namespaces, Singleton pattern.

I would love to see how to implement what I’m trying to do using one of these patterns.

I have no idea which to choose in order to achieve my simple problem: Use objects in other classes, so i don’t need to put anything into __construct’s parameters or using global variables.

I am using __autoload.

I hope i can tackle this problem with your help.

  • 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-06-16T11:48:52+00:00Added an answer on June 16, 2026 at 11:48 am

    First of all, the architecture you’re attempting is extremly bad. Aparently you are using “magic” to create objects attached as properties to other objects. Which is bad, because if you use _get/_set, you will end up in problems sooner rather than later. Also extending from a common parent is a bad thing because it generates huge inheritance trees, and it allows most of the objects to have more than one responsability.

    Before starting a framework, you might want to look over: SOLID

    Now coming back to your question, if you use __get for getting a value, you can as well use __set for setting a value.

    __construct method is there in order to allow you to initialize the object with all the data it needs in order to fulfill his sole purpose. Avoiding the __construct is kinda stupid, and defeats the purpose. You might want to pay attention to the D in SOLID in order to see what Dependency Inversion really is and to understand it.

    Using __set loses completely the ability to typehint interfaces and so on. Therefore the code can become really buggy and ijcredibly hard to follow, since the flow is not so well defined, and the allocation is done in the back via magic. Also i can come up with 1 million other reason for which the architecture you are trying to use is wrong, but i will leave that for another time.

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

Sidebar

Related Questions

Running this command: CREATE ASSEMBLY [System.Web] from 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\system.web.dll' with permission_set = UNSAFE Gives me
I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
So I'm working on a framework-esque system with one of my co-workers. Our current
In my current project, we're using Entity Framework, and in this context to store
I'm porting a legacy system that uses Symfony framework. I have almost no experience
We have this current database which we need to replace some tables by anther
What is current directory of shell script? Is this current directory from which I
I am having a bit of difficulty with this current code I have set
As a beginner in Ocaml, I have this current working code: ... let ch_in
Here is what I have currently, I'm doing this: current_account.send(object).search(params[:search]).user_id_equals_any(users).visibility_is_any(visibilities) but thats not very

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.