複数ネームスペースを可能に
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user