api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autoload.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * An example of a project-specific implementation.
  4. *
  5. * After registering this autoload function with SPL, the following line
  6. * would cause the function to attempt to load the \Foo\Bar\Baz\Qux class
  7. * from /path/to/project/src/Baz/Qux.php:
  8. *
  9. * new \Foo\Bar\Baz\Qux;
  10. *
  11. * @param string $class The fully-qualified class name.
  12. * @return void
  13. */
  14. spl_autoload_register(function ($class) {
  15. // project-specific namespace prefix
  16. $prefix = 'Mevdschee\\PhpCrudApi\\Tests\\';
  17. // base directory for the namespace prefix
  18. $base_dir = __DIR__ . '/';
  19. // does the class use the namespace prefix?
  20. $len = strlen($prefix);
  21. if (strncmp($prefix, $class, $len) !== 0) {
  22. // no, move to the next registered autoloader
  23. return;
  24. }
  25. // get the relative class name
  26. $relative_class = substr($class, $len);
  27. // replace the namespace prefix with the base directory, replace namespace
  28. // separators with directory separators in the relative class name, append
  29. // with .php
  30. $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
  31. // if the file exists, require it
  32. if (file_exists($file)) {
  33. require $file;
  34. }
  35. });