複数ネームスペースを可能に

This commit is contained in:
2026-02-27 03:15:17 +09:00
parent b723230818
commit a1bd29cff6
32 changed files with 95 additions and 73 deletions

View File

@@ -1,9 +1,11 @@
<?php
spl_autoload_register(function ($class): void {
$prefix = 'Site\\';
$prefixes = ['Site\\', 'Std\\'];
$base = realpath(__DIR__.'/src');
$prefixExist = false;
if (strncmp($prefix, $class, strlen($prefix)) !== 0) return;
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;