36 lines
977 B
PHP
36 lines
977 B
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
/**
|
||
* 加载 patches/third_party 中的 GeoIp2 / MaxMind DB Reader(无需 composer 写入 vendor)
|
||
*/
|
||
(function (): void {
|
||
static $loaded = false;
|
||
if ($loaded) {
|
||
return;
|
||
}
|
||
$loaded = true;
|
||
|
||
$base = __DIR__;
|
||
require_once $base . '/maxmind-db/reader/autoload.php';
|
||
|
||
spl_autoload_register(static function (string $class) use ($base): void {
|
||
$map = [
|
||
'GeoIp2\\' => $base . '/geoip2/geoip2/src/',
|
||
'MaxMind\\Exception\\' => $base . '/maxmind/web-service-common/src/Exception/',
|
||
];
|
||
foreach ($map as $prefix => $dir) {
|
||
if (strpos($class, $prefix) !== 0) {
|
||
continue;
|
||
}
|
||
$relative = str_replace('\\', '/', substr($class, strlen($prefix)));
|
||
$path = $dir . $relative . '.php';
|
||
if (is_file($path)) {
|
||
require_once $path;
|
||
}
|
||
return;
|
||
}
|
||
});
|
||
})();
|