25 lines
614 B
PHP
25 lines
614 B
PHP
<?php
|
|
|
|
spl_autoload_register(function ($class) {
|
|
$prefix = 'App\\';
|
|
// base directory for the namespace $prefix
|
|
// __DIR__ entspricht dem aktuellen Pfad
|
|
$base_dir = __DIR__ .'/src/';
|
|
//$base_dir = "/src/";
|
|
// does the class use the namespace prefix?
|
|
|
|
$len = strlen($prefix);
|
|
if (strncmp($prefix, $class, $len) !== 0) {
|
|
// no, move to the next registered autoloader
|
|
return;
|
|
}
|
|
|
|
$relative_class = substr($class, $len);
|
|
|
|
$file = ($base_dir . str_replace('\\', '/', $relative_class) . '.php');
|
|
|
|
if (file_exists($file)) {
|
|
require $file;
|
|
}
|
|
});
|