Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2. define('LIB_SIMPLEAUTOLOAD_AUTOLOAD_PATHS', [
  3. 'Your\\Plugin\\Namespace\\' => __DIR__ . '/src',
  4. ]);
  5.  
  6. spl_autoload_register(function($class) {
  7. $logicalPath = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
  8.  
  9. foreach (LIB_SIMPLEAUTOLOAD_AUTOLOAD_PATHS as $prefix => $path) {
  10. if (strpos($class, $prefix) !== 0)
  11. continue;
  12.  
  13. $path = rtrim($path, '\\/');
  14.  
  15. if (file_exists($dir = $path . DIRECTORY_SEPARATOR . substr($logicalPath, strlen($prefix))))
  16. include $dir;
  17. }
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement