BlueGit

blue-star tribegen

Files

tribegen / web / vendor / autoload.php

autoload.php

fix ignore file
timfa Tim · pushed by timfa · 9 months ago
60fbe0b5 History
autoload.php 776 B Download Raw
1<?php
2
3spl_autoload_register(function ($class) {
4 // Project-specific namespace prefix
5 $prefix = 'TribeGen\\';
6
7 // Base directory for the namespace prefix
8 $base_dir = __DIR__ . '/';
9
10 // Does the class use the namespace prefix?
11 $len = strlen($prefix);
12 if (strncmp($prefix, $class, $len) !== 0) {
13 return;
14 }
15
16 // Get the relative class name
17 $relative_class = substr($class, $len);
18
19 // Replace the namespace prefix with the base directory, replace namespace
20 // separators with directory separators in the relative class name, append
21 // with .php
22 $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
23
24 // If the file exists, require it
25 if (file_exists($file)) {
26 require $file;
27 }
28});