forked from AssemblyPayments/promisepay-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
45 lines (35 loc) · 1.21 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace PromisePay;
spl_autoload_register(function ($class) {
$namespaceLength = strlen(__NAMESPACE__);
if (substr($class, 0, $namespaceLength) != __NAMESPACE__) {
// doesn't belong to our package
return;
}
$classPath = substr($class, $namespaceLength);
$file = __DIR__ . '/lib/' . trim(str_replace('\\', '/', $classPath), '/') . '.php';
if (file_exists($file)) {
require $file;
} else {
printf("%s (path: %s) wasn't found." . PHP_EOL, $class, $file);
printf(
'Debug backtrace: %s' . PHP_EOL,
print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true)
);
die();
}
});
// Was the package installed through Composer?
// If not, fallback to included versions of vendor files
$httpfulFiles = array(
__DIR__ . '/lib/Vendors/Httpful/Bootstrap.php',
__DIR__ . '/lib/Vendors/Httpful/Http.php',
__DIR__ . '/lib/Vendors/Httpful/Request.php'
);
if (!class_exists('Httpful\Request')) {
foreach ($httpfulFiles as $file) {
require_once $file;
}
// polyfill for array_column
require_once __DIR__ . '/lib/Vendors/ramsey/array_column/src/array_column.php';
}