basic website, basic templating
This commit is contained in:
18
src/bootstrap.php
Normal file
18
src/bootstrap.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(callback: function($className) {
|
||||
$prefix = 'App';
|
||||
$baseDir = __DIR__;
|
||||
|
||||
$len = strlen(string: $prefix);
|
||||
if (strncmp(string1: $prefix, string2: $className, length: $len) !== 0) {
|
||||
return;
|
||||
}
|
||||
$realClassName = substr(string: $className, offset: $len);
|
||||
$classLocation = $baseDir . str_replace(search: '\\', replace: '/', subject: $realClassName) . '.php';
|
||||
if (file_exists(filename: $classLocation)) {
|
||||
require $classLocation;
|
||||
} else {
|
||||
die("Invalid class: $className");
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user