Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/02/2012, 13:55
topikito
 
Fecha de Ingreso: abril-2007
Mensajes: 12
Antigüedad: 17 años
Puntos: 0
Pregunta Problema con AutoLoader

Hola chicos,

Llevo por lo menos una semana buscando en Internet. Pensé que mi problema sería una tontería (otras veces que he trabajado con ZF no me ha pasado) pero tras patearme todo google buscando la solución no he dado con la misma.

Estoy intentando hacer una base "CMS" en Zend para luego extenderla con más funcionalidades dependiendo del proyecto que tenga que desarrollar.

Estoy empezando por los usuarios y estoy intentando crear la "Admin". (Tengo el proyecto en [URL="https://github.com/topikito/zendcms"]GitHub[/URL] si lo quieren ver por ahí) Tengo la siguiente estructura:



En mi index lo siguiente:

Código PHP:
<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || 
define('APPLICATION_PATH'realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV')
    || 
define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    
realpath(APPLICATION_PATH '/../library'),
    
get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    
APPLICATION_ENV,
    
APPLICATION_PATH '/configs/application.ini'
);
$application->bootstrap()
            ->
run();
En el Bootstrap:

Código PHP:
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    protected function 
_initAutoload() {
    
        
$autoloader = new Zend_Application_Module_Autoloader(array(
                    
'namespace' => 'Application',
                    
'basePath' => dirname(__FILE__),
                ));

    
//var_dump($autoloader);

        
return $autoloader;
    }

    protected function 
_initDoctype() {
        
$this->bootstrap('view');
        
$view $this->getResource('view');
        
$view->doctype('XHTML1_STRICT');
    }

}
Luego tengo la clase User en "models" que (no voy a copiarlo todo) empieza así:

Código PHP:
<?php

class Application_Model_User
{...}
Finalmente, el controlador del módulo "admin":
Código PHP:
<?php

//require APPLICATION_PATH.'/modules/default/models/User.php';

class Admin_UserController extends Zend_Controller_Action
{
    public function 
indexAction()
    {
        
$User = new Application_Model_User();
        
$this->view->entries $User->fetchAll();
    }
}
Sólo quiero hacer un fetchAll para ver que funciona. Si descomento el require en un par de sitios, funciona, pero esa no es la manera.

Obtengo el siguiente error:

Código:
2012/02/28 20:46:47 [error] 12171#0: *193 FastCGI sent in stderr: "PHP Fatal error:  Class 'Application_Model_User' not found in /mnt/www-host/ZendCMS/application/modules/admin/controllers/UserController.php on line 9
PHP Stack trace:
PHP   1. {main}() /mnt/www-host/ZendCMS/index.php:0
PHP   2. Zend_Application->run() /mnt/www-host/ZendCMS/index.php:26
PHP   3. Zend_Application_Bootstrap_Bootstrap->run() /mnt/www-host/ZendCMS/library/Zend/Application.php:366
PHP   4. Zend_Controller_Front->dispatch() /mnt/www-host/ZendCMS/library/Zend/Application/Bootstrap/Bootstrap.php:97
PHP   5. Zend_Controller_Dispatcher_Standard->dispatch() /mnt/www-host/ZendCMS/library/Zend/Controller/Front.php:954
PHP   6. Zend_Controller_Action->dispatch() /mnt/www-host/ZendCMS/library/Zend/Controller/Dispatcher/Standard.php:295
PHP   7. Admin_UserController->indexAction() /mnt/www-host/ZendCMS/library/Zend/Controller/Action.php:513" while reading upstream, client: 192.168.1.128, server: zendcms.loc, request: "GET /admin/user HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "www.zendcms.loc"
Por si sirve de algo, he hecho un var_dump del $autoloader:

Código PHP:
object(Zend_Application_Module_Autoloader)[12]
  protected 
'_basePath' => string '/mnt/www-host/ZendCMS/application' (length=33)
  protected 
'_components' => 
    array
      
'Application_Model_DbTable' => string '/mnt/www-host/ZendCMS/application/models/DbTable' (length=48)
      
'Application_Model_Mapper' => string '/mnt/www-host/ZendCMS/application/models/mappers' (length=48)
      
'Application_Form' => string '/mnt/www-host/ZendCMS/application/forms' (length=39)
      
'Application_Model' => string '/mnt/www-host/ZendCMS/application/models' (length=40)
      
'Application_Plugin' => string '/mnt/www-host/ZendCMS/application/plugins' (length=41)
      
'Application_Service' => string '/mnt/www-host/ZendCMS/application/services' (length=42)
      
'Application_View_Helper' => string '/mnt/www-host/ZendCMS/application/views/helpers' (length=47)
      
'Application_View_Filter' => string '/mnt/www-host/ZendCMS/application/views/filters' (length=47)
  protected 
'_defaultResourceType' => string 'model' (length=5)
  protected 
'_namespace' => string 'Application' (length=11)
  protected 
'_resourceTypes' => 
    array
      
'dbtable' => 
        array
          
'namespace' => string 'Application_Model_DbTable' (length=25)
          
'path' => string '/mnt/www-host/ZendCMS/application/models/DbTable' (length=48)
      
'mappers' => 
        array
          
'namespace' => string 'Application_Model_Mapper' (length=24)
          
'path' => string '/mnt/www-host/ZendCMS/application/models/mappers' (length=48)
      
'form' => 
        array
          
'namespace' => string 'Application_Form' (length=16)
          
'path' => string '/mnt/www-host/ZendCMS/application/forms' (length=39)
      
'model' => 
        array
          
'namespace' => string 'Application_Model' (length=17)
          
'path' => string '/mnt/www-host/ZendCMS/application/models' (length=40)
      
'plugin' => 
        array
          
'namespace' => string 'Application_Plugin' (length=18)
          
'path' => string '/mnt/www-host/ZendCMS/application/plugins' (length=41)
      
'service' => 
        array
          
'namespace' => string 'Application_Service' (length=19)
          
'path' => string '/mnt/www-host/ZendCMS/application/services' (length=42)
      
'viewhelper' => 
        array
          
'namespace' => string 'Application_View_Helper' (length=23)
          
'path' => string '/mnt/www-host/ZendCMS/application/views/helpers' (length=47)
      
'viewfilter' => 
        array
          
'namespace' => string 'Application_View_Filter' (length=23)
          
'path' => string '/mnt/www-host/ZendCMS/application/views/filters' (length=47
No veo donde estoy fallando y he probado de todo. Alguien tiene alguna idea de qué puede ser?