forked from yiichou/aliyun-oss-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoload.php
31 lines (28 loc) · 934 Bytes
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* An example of a project-specific implementation.
*
* After registering this autoload function with SPL, the following line
* would cause the function to attempt to load the \Foo\Bar\Baz\Qux class
* from /path/to/project/src/Baz/Qux.php:
*
* new \Foo\Bar\Baz\Qux;
*
* @param string $class The fully-qualified class name.
* @return void
*/
spl_autoload_register(function ($class) {
$auto_load_class = array(
'OSS\\WP\\' => '/src/',
'OSS\\' => '/vendor/aliyuncs/oss-sdk-php/src/OSS/'
);
foreach ($auto_load_class as $prefix => $base_dir) {
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) == 0) {
$relative_class = substr($class, $len);
$file = ALIYUN_OSS_PATH . $base_dir . str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php';
if (file_exists($file))
require $file;
}
}
});