bootstrap.php 781 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. const DIR_CONFIG = '/../config';
  3. spl_autoload_register(function ($className) {
  4. $paths = include __DIR__ . DIR_CONFIG . '/path.php';
  5. $className = str_replace('\\', '/', $className);
  6. foreach ($paths['classes'] as $path) {
  7. $filename = $_SERVER['DOCUMENT_ROOT'] . "/$paths[root]/$path/$className.php";
  8. if (file_exists($filename)) {
  9. require_once $filename;
  10. }
  11. }
  12. });
  13. function getConfigs(string $path = DIR_CONFIG): array {
  14. $settings = [];
  15. foreach (scandir(__DIR__ . $path) as $file) {
  16. $name = explode('.', $file)[0];
  17. if (!empty($name)) {
  18. $settings[$name] = include __DIR__ . "$path/$file";
  19. }
  20. }
  21. return $settings;
  22. }
  23. return new Src\Application(new Src\Settings(getConfigs()));