mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2026-09-04 23:12:09 +08:00
28 lines
816 B
PHP
28 lines
816 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$autoloadCandidates = [
|
|
dirname(__DIR__) . '/vendor/autoload.php',
|
|
dirname(__DIR__, 2) . '/vendor/autoload.php',
|
|
dirname(__DIR__, 3) . '/vendor/autoload.php',
|
|
];
|
|
|
|
foreach ($autoloadCandidates as $autoloadFile) {
|
|
if (is_file($autoloadFile)) {
|
|
require $autoloadFile;
|
|
spl_autoload_register(static function (string $class): void {
|
|
$prefix = 'We\\';
|
|
if (str_starts_with($class, $prefix)) {
|
|
$path = dirname(__DIR__) . '/src/' . str_replace('\\', '/', substr($class, strlen($prefix))) . '.php';
|
|
if (is_file($path)) {
|
|
require $path;
|
|
}
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
|
|
throw new RuntimeException('Cannot locate Composer autoload.php for We tests.');
|