Okay, I really need some help here, lol. This may be a bit long, but it's really important that I get this going soon.
Basically, what I'm trying to do is build an API that has built-in and extendable sub-API classes.
API is a class, and within are some basic functions that all of the sub-APIs need to call, like confGetKey, ect. Now, all of the sub-APIs should be contained within the main API class, so calling something in a subAPI would work like $API->subAPI->someFunction();.
Now, here's were it gets tricky. As I already said, subAPI needs to make calls to some base API functions. So, subAPI->someFunction(); needs to get a confKey from the base class using the function confGetKey. Also, inside some of subAPI's functions, calls need to be made to other subAPIs. The thing is, all of these sub-APIs have their own properties, and only one of each should be made.
So, my initial idea, was to do something like this:
$API->subAPI = new subAPI(&$API);
Then, in subAPI's constructor, the reference to $API would be stored, and then I would make a call like $this->API->otherSubAPI->function inside of the sub-API. But, and maybe I did it wrong, I was getting call-time pass-by-reference errors, and then it told me that I was calling a method of a non-object.
So, that's my dilemma. I've read a bunch of tutorials and articles on OOP in PHP, and have yet to find a suitable way to create this kind of hierarchy.
Is there any other decent ways to do this that don't require hacks and work-arounds? I want this to be a very very solid API/framework that will basically be self contained.
Thank you in advance for any advice you can offer.
Regards,
Darryl Millar