I'm currently developing a framework which uses an object of a Core
class (this class has huge functionality & makes the framework working). The framework follows MVC architecture & has loosely coupled Model, Control, View classes. Theses classes need a reference to the Core
class heavily. What I've done so far is: creating single object of the Core
class & referencing to it by PHP keyword global
in Model, Control, View classes.
I don't like using this approach mainly because:
- This way is not true object oriented way in my sense
- The IDE (netbeans) can't provide documentation to the object of the
Core
class - a pain for developers who will be using this framework. - I'm really worried about performance issues - have no idea whether
global
is slower or whatever.
I've searched & did not find any information regarding performance issue. I've also searched stackoverflow & found Does using global create any overhead? & The advantage / disadvantage between global variables and function parameters in PHP? etc links but they don't contain much information. Right now my main concern is performance, so please help.