autoload.php 804 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Users who do not have 'composer' to manage dependencies, include this
  4. * file to provide auto-loading of the classes in this library.
  5. */
  6. spl_autoload_register ( function ($class) {
  7. /*
  8. * PSR-4 autoloader, based on PHP Framework Interop Group snippet (Under MIT License.)
  9. * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
  10. */
  11. $prefix = "Mike42\\";
  12. $base_dir = __DIR__ . "/src/Mike42/";
  13. /* Only continue for classes in this namespace */
  14. $len = strlen ( $prefix );
  15. if (strncmp ( $prefix, $class, $len ) !== 0) {
  16. return;
  17. }
  18. /* Require the file if it exists */
  19. $relative_class = substr ( $class, $len );
  20. $file = $base_dir . str_replace ( '\\', '/', $relative_class ) . '.php';
  21. if (file_exists ( $file )) {
  22. require $file;
  23. }
  24. } );