-
Notifications
You must be signed in to change notification settings - Fork 34
/
autoload.php
47 lines (45 loc) · 1.76 KB
/
autoload.php
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
<?php
/**
* This file will autoload KoolReport class when included
*
* @category Core
* @package KoolReport
* @author KoolPHP Inc <[email protected]>
* @copyright 2017-2028 KoolPHP Inc
* @license MIT License https://www.koolreport.com/license#mit-license
* @link https://www.koolphp.net
*/
$packageFolders = glob(dirname(__FILE__)."/../*", GLOB_ONLYDIR);
foreach ($packageFolders as $folder) {
$packageVendorAutoLoadFile = $folder."/vendor/autoload.php";
if (is_file($packageVendorAutoLoadFile)) {
include_once $packageVendorAutoLoadFile;
}
}
spl_autoload_register(
function ($classname) {
if (strpos($classname, "koolreport\\")!==false) {
$dir = str_replace("\\", "/", dirname(__FILE__));
$classname = str_replace("\\", "/", $classname);
$filePath = $dir."/".str_replace("koolreport/", "src/", $classname).".php";
//try to load in file
if (is_file($filePath)) {
include_once $filePath;
} else {
//try to load in packages in the same level with core
$dir = str_replace("\\", "/", dirname(dirname(__FILE__)));
$filePath = $dir."/".str_replace("koolreport/", "", $classname).".php";
if (is_file($filePath)) {
include_once $filePath;
} else {
//Try to load pakages in packages folder inside core
$dir = str_replace("\\", "/", dirname(__FILE__));
$filePath = $dir."/".str_replace("koolreport/", "packages/", $classname).".php";
if (is_file($filePath)) {
include_once $filePath;
}
}
}
}
}
);