I uploaded my project to a free shared hosting. I do not render the views as they should be, that is, everything loads me well but does not show content, only the blank page appears. I tried placing a php page with conventional html and everything works fine.
PS: Locally I use a virtual host and everything works well for me.
declare(strict_types = 1); namespace app\core\librarys; use app\core\helpers\FunctionsTwig;class View { public static function create(string $path, array $params=null){ //Convertir el string recibido en array $path = explode('.',$path); $route = null; /*Crear mediante ciclo el formato ruta del archivo requerido*/for ($i=0; $i < count($path); $i++){ if ($i == count($path)-1){ /*Si es el ultimo se le anexa la extencion del archivo*/ $route.=$path[$i].'.twig'; }else{ /*Mientras se sigue formando la ruta*/ $route.=$path[$i].'/'; } } /* Comprobar si la ruta obtenida del archivo es verdadera */ if (file_exists(VIEWS_PATH.'templates/'.$route)){ /* Se le establece donde estaran las vistas */ $loader = new \Twig_Loader_Filesystem(VIEWS_PATH.'templates/'); /* Se le configuran opciones */ $twig = new \Twig_Environment($loader,[ 'cache'=> VIEWS_PATH.'cache/' ]); /* Agregar variables globales */ add_twig_global($twig, array( 'URL_ASSETS' => URL_BASE.'public/assets/', 'URL_TS' => URL_BASE.'public/typescript/output/src/' )); /* Extension para poder crear funciones personalizadas */ $twig->addExtension(new FunctionsTwig()); if (is_null($params))echo $twig->render($route);else echo $twig->render($route, $params); }else{ die('No existe el archivo'); } }
}