Move libraries to autoload format

This commit is contained in:
Antonio de la Rosa 2025-11-26 00:02:19 +01:00
parent 7ac0f6c850
commit b4f758f0b5
8 changed files with 1009 additions and 23 deletions

View file

@ -4,8 +4,8 @@ use PhangoApp\PhaUtils\Utils;
ob_start();
include('libraries/Utils.php');
include('libraries/Routes.php');
//include('libraries/Utils.php');
//include('libraries/Routes.php');
if(is_file(__DIR__.'/vendor/autoload.php')) {
@ -15,8 +15,6 @@ if(is_file(__DIR__.'/vendor/autoload.php')) {
//ob_start();
Utils::load_config('config');
spl_autoload_register(function($class_name) {
//Simple autoload for modules, first element is module, second element is the file to load.
@ -26,23 +24,34 @@ spl_autoload_register(function($class_name) {
if(count($arr_library)>1) {
$module=strtolower($arr_library[0]);
$library=strtolower($arr_library[1]);
$last_path=implode('/', array_slice($arr_library, 1, count($arr_library)));
$library=strtolower($last_path);
if(is_file('modules/'.$module.'/libraries/'.$library.'.php')) {
include('modules/'.$module.'/libraries/'.$library.'.php');
}
else if(is_file('modules/'.$module.'/libraries/'.strtolower($arr_library[1]).'.php')) {
include('modules/'.$module.'/libraries/'.strtolower($arr_library[1]).'.php');
}
}
});
Utils::load_config('config');
if(!PhangoApp\PhaRouter\Config::$on_other) {
if(!PhangoApp\PhaRouter\Config::$get_path_info) {
$path_info=isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
}
else {