-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoload.php
More file actions
70 lines (62 loc) · 1.98 KB
/
autoload.php
File metadata and controls
70 lines (62 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Config;
require_once "errorhandler.php";
session_start();
include "config.php";
/**
* @category Configuration
*/
// Function to autoload classes from a directory and its subdirectories
function autoloadClasses($dir) {
// Check if the directory exists
if (!is_dir($dir)) {
// Output an error message and return
echo "Error: Directory '$dir' not found.\n";
return;
}
// Get all files and directories under the specified directory
$files = scandir($dir);
// Iterate over each file/directory
foreach ($files as $file) {
// Skip current and parent directory links
if ($file == '.' || $file == '..') continue;
// Construct the full path
$path = $dir . '/' . $file;
// If the current item is a directory, recursively autoload from it
if (is_dir($path)) {
autoloadClasses($path);
}
// If the current item is a PHP file, include it
elseif (is_file($path) && pathinfo($path, PATHINFO_EXTENSION) == 'php') {
include_once $path;
}
}
}
require_once "core/helpers.php";
autoloadClasses(__DIR__.'\core');
autoloadClasses(__DIR__.'\App\models');
class Config
{
public static $root_url;
public static $root_path;
public static $middleware;
private static $config = [];
public function set($key,$value){
self::$config[$key] = $value;
}
public function get($key){
return self::$config[$key] ?? null;
}
public static function init()
{
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
self::$root_url = $protocol . "://" . $_SERVER['HTTP_HOST'];
self::$root_path = $_SERVER['DOCUMENT_ROOT'];
}
}
Config::init();
use Core\Helper;
Helper::load_env();
require_once __DIR__."/App/Helpers/helper.php";
ini_set("SMTP",$_ENV['SMTP_HOST']);
ini_set("SMTP_PORT",$_ENV['SMTP_PORT']);