autoloader.php 965 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. //preloading of some required libs
  3. include('api/staticloader.php');
  4. //Register and load file classes
  5. spl_autoload_register(function ($className) {
  6. $api_directory = 'api' . DIRECTORY_SEPARATOR;
  7. $libs_directory = 'libs' . DIRECTORY_SEPARATOR;
  8. // Defined path
  9. $classFileName = strtolower($className);
  10. $apiClassFileName = $api_directory . $libs_directory . 'api.' . $classFileName . '.php';
  11. if (strpos($className, 'nya_') !== false) {
  12. $notOrmTable = str_replace("nya_", '', $className);
  13. $exec = '
  14. class ' . $className . ' extends NyanORM {
  15. public function __construct() {
  16. parent::__construct();
  17. $this->tableName = "' . $notOrmTable . '";
  18. }
  19. }';
  20. eval($exec); //automatic models generation
  21. } else {
  22. if (file_exists($apiClassFileName)) {
  23. include $apiClassFileName;
  24. }
  25. }
  26. });
  27. ?>