Классы внутри vendor подтягиваются из внутренней директории src.

This commit is contained in:
Ivor Barhansky 2024-04-26 15:47:32 +03:00
parent 4470f80098
commit 60ac124ea9

View File

@ -10,13 +10,18 @@ require_once 'mysql_override.php';
spl_autoload_register(function (string $className) {
$rootdir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '_incl_data' . DIRECTORY_SEPARATOR;
$addsrc = function ($class) {
$c = explode('\\', $class);
array_splice($c, 1, 0, 'src');
return implode(DIRECTORY_SEPARATOR, $c);
};
# 1 with namespaces
# 2 without
$fileName = [
$rootdir . 'class' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
$rootdir . 'class' . DIRECTORY_SEPARATOR . $className . '.php',
$rootdir . 'function' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
$rootdir . 'vendor' . DIRECTORY_SEPARATOR . $className . '.php',
$rootdir . 'vendor' . DIRECTORY_SEPARATOR . $addsrc($className) . '.php',
];
foreach ($fileName as $file) {
if (file_exists($file)) {