<?php

use PhangoApp\PhaUtils\Utils;

ob_start();

include('libraries/Utils.php');
include('libraries/Routes.php');

/*spl_autoload_register(function ($class_name) {
    
    //include($nombre_clase . '.php';
    //echo $class_name;
    switch($class_name) {
    
        case 'PhangoApp\PDO\MySQL':
        
            include('./libraries/PDO.php');
        
        break;
    
    }
    
});*/

if(is_file(__DIR__.'/vendor/autoload.php')) {

    include(__DIR__.'/vendor/autoload.php');
    
}

//ob_start();

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 {

        $path_info=str_replace(PhangoApp\PhaRouter\Config::$base_url.'index.php', '', $_SERVER['REQUEST_URI']);

        if($path_info===PhangoApp\PhaRouter\Config::$base_url) {

            $path_info='';

        }

    }

}
else {
    
    if(!isset($_GET['path_info'])) {
    
        $path_info='';
        
    }
    else {
        
        $path_info=$_GET['path_info'];
        
    }
    
}

echo \PhangoApp\PhaRouter\get_route($path_info);

//ob_end_flush();
$final_content=ob_get_contents();

ob_end_clean();

echo $final_content;
