-
Notifications
You must be signed in to change notification settings - Fork 64
/
autoload.php
39 lines (37 loc) · 1.3 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
<?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__)."/packages/*", 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
$filePath = $dir."/".str_replace("koolreport/", "packages/", $classname).".php";
if (is_file($filePath)) {
include_once $filePath;
}
}
}
}
);