Ver Mensaje Individual
  #6 (permalink)  
Antiguo 01/01/2016, 12:46
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: problemas con namespace y use

Mira intenté hacer un autoload para solucionar el problema pateketrueke:

Código PHP:
Ver original
  1. <?php
  2.     function mi_autocargador($clase) {
  3.         $support = array('App','Clases', 'Controller,Model');
  4.         $classString = '';
  5.         foreach($support as $value) {
  6.             $classString = $value.'/'.$clase.'.php';
  7.             if(file_exists($classString)){
  8.                 require_once $classString;
  9.             }            
  10.         }
  11.     }
  12.     spl_autoload_register('mi_autocargador');
  13.     $controlador = (!empty($_GET['c'])) ? ucwords($_GET['c']) . 'Controller' : "MainController";
  14.     $accion = (!empty($_GET['a'])) ? $_GET['a'] : "index";
  15.     $ruta = "Controller/" . $controlador . ".php";
  16.     try{
  17.         require_once $ruta;
  18.         $controlo = new $controlador();
  19.         $controlo->$accion();
  20.     }
  21.     catch (Exception $ex) {
  22.         echo $ex->getMessage();
  23.     }

pero me sale el mismo error:

Fatal error: Class 'App\Controller' not found in /var/www/html/amnesia_1/Controller/MainController.php on line 5

No se me ocurre solución alguna.... ¿que hacer?

espero respuestas y saludos.

Pd: Feliz año nuevo