Autoloader.php 576 B

1234567891011121314151617181920212223
  1. <?php
  2. if(!defined('WORKERMAN_ROOT_DIR'))
  3. {
  4. define('WORKERMAN_ROOT_DIR', realpath(__DIR__ . '/../'));
  5. }
  6. require_once WORKERMAN_ROOT_DIR.'/Workerman/Lib/Constants.php';
  7. function workerman_loader($name)
  8. {
  9. $class_path = str_replace('\\', DIRECTORY_SEPARATOR ,$name);
  10. $class_file = WORKERMAN_ROOT_DIR . DIRECTORY_SEPARATOR . "$class_path.php";
  11. if(is_file($class_file))
  12. {
  13. require_once($class_file);
  14. if(class_exists($name, false))
  15. {
  16. return true;
  17. }
  18. }
  19. return false;
  20. }
  21. spl_autoload_register('workerman_loader');