Files
LittleBeast/autoload.php

13 lines
532 B
PHP

<?php
spl_autoload_register(function ($class): void {
$prefixes = ['Site\\', 'Std\\'];
$base = realpath(__DIR__.'/src');
$prefixExist = false;
foreach ($prefixes as $prefix) { if (strncmp($prefix, $class, strlen($prefix)) === 0) $prefixExist = true; }
if (!$prefixExist) return;
$ps = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = $base.DIRECTORY_SEPARATOR.$ps.'.php';
if (file_exists($file)) require $file;
else error_log("クラス{$class}を見つけられません。試したパス:{$file}");
});