39 lines
1.3 KiB
PHP
Executable File
39 lines
1.3 KiB
PHP
Executable File
<?php
|
|
/*
|
|
* An example of a project-specific implementation.
|
|
* @param string $class The fully-qualified class name.
|
|
* @return void
|
|
*/
|
|
spl_autoload_register(function ($class) {
|
|
// project-specific namespace prefix
|
|
$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?
|
|
//echo "</br>base_dir: ".$base_dir; //die();
|
|
|
|
$len = strlen($prefix);
|
|
if (strncmp($prefix, $class, $len) !== 0) {
|
|
// no, move to the next registered autoloader
|
|
return;
|
|
}
|
|
|
|
// get the relative class name
|
|
$relative_class = substr($class, $len);
|
|
// replace the namespace prefix with the base directory, replace namespace
|
|
// separators with directory separators in the relative class name, append
|
|
// with .php
|
|
//echo "</br>relative class: ".$relative_class; //die();
|
|
$file = ($base_dir . str_replace('\\', '/', $relative_class) . '.php');
|
|
//echo "</br>file: ".$file; //die();
|
|
// if the file exists, require it
|
|
if (file_exists($file)) {
|
|
require $file;
|
|
//echo "</br>file required: ".$file; //die();
|
|
} else {
|
|
//echo "</br>kein File: ".$file." vorhanden "; //die();
|
|
}
|
|
});
|