Wymyśliłem coś takiego:
<?php class core { private $handle; public function __get($name) { return $this->handle[$name]; } public function __set($name, $value) { $this->handle[$name] = $value; return true; } public function _load($file) { if ($this->$file) { return $this->$file; }else{ include_once('class/'.$file.'.php'); return $this->$file = new $file; } } } ?>
Użycie:
<?php $core = new core(); $test = $core->_load('test'); $core->test->a(); $test->a(); ?>
To rozwiązanie jest troszkę podpatrzone z ZF ale ręcznie trzeba ładować zamiast automatycznie. ;p (jak to zrobili w ZF ?)
Tylko klasy chciałbym podzielić np. na te do obsługi baz danych, grafiki, xml etc.