Ver Mensaje Individual
  #10 (permalink)  
Antiguo 13/02/2016, 21:04
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: Estructurar Sistema en PHP

Hola a todos, al final lo logré sólo tenía que usar glob para recorrer las carpetas y obtener el bundle:

Código PHP:
Ver original
  1. <?php
  2.     define("APPLICATION_PATH", dirname(__FILE__));
  3.     define("DS", DIRECTORY_SEPARATOR);
  4.     spl_autoload_register(function($clase) {
  5.         try {
  6.             require_once APPLICATION_PATH . DS . str_replace("\\", DS, $clase) . ".php";        
  7.         }
  8.         catch (Exception $ex) {
  9.             echo $ex->getMessage();
  10.         }
  11.     });
  12.     $controlador = (!empty($_GET['c'])) ? ucwords($_GET['c']) . 'Controller' : "MainController";
  13.     $accion = (!empty($_GET['a'])) ? $_GET['a'] : "index";
  14.     foreach(glob(APPLICATION_PATH . DS . "Src". DS . "*") as $dir) {
  15.         foreach(glob($dir . DS . "Controller" . DS . "*") as $file){
  16.             $c = str_replace($dir . DS . "Controller" . DS, "", $file);
  17.             $c2 = str_replace(".php","",$c);
  18.             if($c2 == $controlador){
  19.                 $bundle = str_replace(APPLICATION_PATH . DS . "Src". DS, "", $dir);                
  20.             }
  21.         }
  22.     }        
  23.     try {
  24.         $controlador = "Src\\". $bundle . "\\Controller\\" . $controlador;
  25.         $controlo = new $controlador();
  26.         $controlo->$accion();
  27.     } catch (Exception $ex) {
  28.         echo $ex->getMessage();
  29.     }

y mi repositorio esta actualizado: https://github.com/detectivejd/amnesia_php_hmvc

Mil gracias a todos...