error al generar sistema spl_autoload_register

Iniciado por vhugo_rf, 8 Agosto 2016, 17:54 PM

0 Miembros y 1 Visitante están viendo este tema.

vhugo_rf

Hola cómo están, estoy intentando crear un sistema de autoloading con namespace y MVC al correr en local no hay problema sino al subir los archivos al servidor de producción arroja un error 500.

El servidor de producción tiene

PHP Version 5.5.36

y en local trabajo con

PHP Version 5.5.9

el error en el log es el siguiente

PHP Fatal error:  Class 'lib\Config' not found in /home/*******/public_html/proyecto/app/controller/homeController.php on line 3

mi archivo homeController.php es


<?php
namespace controller;
$config = \lib\Config::getInstance();
$h = new \lib\service\Home();
new \
test\Test();
if(isset(
$_POST['axn'])):
else:
    require_once(
"app/view/home/home.phtml");
endif;


este es mi código index

<?php
$vars 
$_REQUEST;
$action = ((!empty($vars['action'])) ? $vars['action'] : "home");
$file = ((is_file("app/controller/" $action "Controller.php")) ? "app/controller/" $action "Controller.php" "app/controller/errorController.php");

spl_autoload_register(function($clase){
$DS DIRECTORY_SEPARATOR
$className explode('\\'$clase);
$class array_pop($className);
$namespace implode($DS$className);

$axn = ((!empty($_GET['action'])) ? $_GET['action'] : "home");

$libPath 'app' $DS strtolower($clase) . '.class.php';
$modelPath ='app' $DS $namespace $DS $axn 'Model.php';
$contollerPath 'app' $DS $namespace $DS $axn 'Controller.php';
$sqlPath 'app' $DS $namespace $DS $axn '.class.php';
if(!
is_file($libPath) &&
    !
is_file($modelPath) &&
    !
is_file($contollerPath) &&
    !
is_file($sqlPath)):
    
$contollerPath 'app' $DS $namespace $DS 'errorController.php';
    
$modelPath ='app' $DS $namespace $DS 'errorModel.php';
endif;

if(
is_readable($libPath)):
    require_once(
$libPath);
elseif(
is_readable($modelPath)):
    require_once(
$modelPath);
elseif(
is_readable($contollerPath)):
    require_once(
$contollerPath);
elseif(
is_readable($sqlPath)):
    require_once(
$sqlPath);
endif;
 });
 require_once(
$file);


esta es la estructura de archivos
https://drive.google.com/file/d/0BxtDHt_IfKf6U2xCMXJ6cFdvNzg/view?pref=2&pli=1

Muchas gracias, espero me puedan ayudar

[u]nsigned

Los errores 500 generalemnte son por una mala configuracion o conflicto en .htaccess. Podrias publicar su contenido?

Seguramente por eso no te funcionan las rutas relativas, el error que te tira dice que no encuentra la clase lib/Config. O estas usando mal las rutas o tenes las redirecciones de apache mal confguradas.

No hay atajo ante la duda, el misterio se hace aquí...
Se hace carne en cada uno, el misterio es existir!