I was working on my core class which looks like this: 

```
require 'core.conf.php';

class Core {
    public function __construct() {
        $autoloader = new classAutoloader();
        $this->instantiateObjects();    
    }

    private function instantiateObjects() {
        $handle = opendir(__DIR__);
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                if ($file != "core.class.php" && !in_array($file, $file_exceptions)) {
                    $class_name = str_replace('.class.php', '', $file);
                                        $this->$class_name = new $class_name();
                }
            }
        }
        closedir($handle);
    }
}

class classAutoloader extends Core {
    public function __construct() {
        spl_autoload_register(array($this, 'loadClass'));
    }

    private function loadClass($class_name) {
        require $class_name . '.class.php';
    }
}

```

It loads all the classes and instantiates them into one core.
So that I would be able to do this:

```
$core = new Core();

```

And access all the loaded classes like this:

```
$core->database->foo();
$core->template->foo();

```

Now that works completely fine, but if I want to use e.g. database in the template class I'd have to add global $core to every function that needs to access the database, but I don't want to global all the time. What's the correct way of solving this? Would it matter if I made all the classes static? I'd prefer using -> instead of :: though. I hope you could help me out!