Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2010, 12:44
Droller
 
Fecha de Ingreso: diciembre-2006
Mensajes: 15
Antigüedad: 17 años, 4 meses
Puntos: 0
Sonrisa Problema enrutamiento en ZF

Buenas, recurro a ustedes con el siguiente problema.

Tengo congifurada mi aplicación con una clase Bootstrap y la ayuda de Zend_Application.
Mi problema es que el enrutamiento no funciona correctamente; ejemplo:

http://localhost/miproyecto/public/auth/login , debería pegarle al AuthController y a loginAction, sin embargo me tira el error de que no encuentra el directorio "public/auth/login".

No entiendo por qué se puede estar dando este problema, yo pensaba que ZF entendia directamente lo de "public/:controller/:action", pero se ve que hay que hacer algo más.

A continuacion detallo mi clase Bootstrap y demás:

Bootstrap.php:

Código PHP:
final class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function 
_initRequest()
    {
        
$this->bootstrap('FrontController');
        
        
$front $this->getResource('FrontController');
        
        
$request = new Zend_Controller_Request_Http();
        
        
$front->setRequest($request);
        
        return 
$request;
    }
    
    protected function 
_initView()
    {
        
$view = new Zend_View();
        
$view->doctype('XHTML1_STRICT');
        
$view->headTitle('Administrador de cursos');
        
$view->headLink()->appendStylesheet($view->baseUrl().'/css/main.css');
        
        
$viewRenderer Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        
$viewRenderer->setView($view);

        return 
$view;
    }
    
    protected function 
_initPluginResource()
    {
        
$dbs $this->getPluginResource('db');
        
$adapter $dbs->getAdapter();
        
        
$db Zend_Db::factory($adapter,$dbs->getParams());
        
Zend_Db_Table_Abstract::setDefaultAdapter($db);
        
        return 
$dbs;
    }
    
    protected function 
_initAutoload()
    {
        
$autoloader = new Zend_Application_Module_Autoloader(array(
            
'namespace' => '',
            
'basePath' => APPLICATION_PATH    
        
));
        
        return 
$autoloader;
    }

index.php:

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();

application.ini

Código PHP:
[production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1

;IncludePaths
includePaths
.library APPLICATION_PATH "/../library"

;Bootstrap
bootstrap
.path APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

;Front controller
resources
.frontController.controllerDirectory APPLICATION_PATH "/controllers"
resources.frontController.plugins.auth "My_Plugin_Auth"
autoloaderNamespaces[] = "My_"

;View
resources
.view.encoding "UTF-8"
resources.view.basePath APPLICATION_PATH "/views/scripts"

;Layout
resources
.layout.layout "main"
resources.layout.layoutPath APPLICATION_PATH "/layouts/scripts"

;DataBase
resources
.db.adapter "pdo_mysql"
resources.db.params.host "localhost"
resources.db.params.username "root"
resources.db.params.password "101757"
resources.db.params.dbname "cursos"
resources.db.isDefaultTableAdapter true

[staging production]

[
testing production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 1

[development production]
phpSettings.display_startup_errors 1
phpSettings
.display_errors 
Graciass anticipadass.

Saludos