Foros del Web » Programando para Internet » PHP » Zend »

Cargar Plugins en Zend framework

Estas en el tema de Cargar Plugins en Zend framework en el foro de Zend en Foros del Web. Estoy intentado cargar los plugins en zend framework pero no consigo cargarlo siempre me da el error de clase no encontrada , se que el ...
  #1 (permalink)  
Antiguo 06/03/2010, 08:50
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 8 meses
Puntos: 0
Cargar Plugins en Zend framework

Estoy intentado cargar los plugins en zend framework pero no consigo cargarlo siempre me da el error de clase no encontrada , se que el error esta en el APPLICATION_PATH, y en el autoloader...he probado de mil maneras pero me he quedado atascado y no sale.

En el boostrap tengo:

Código PHP:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function 
_initAutoload()
    {
       
$autoloader = new Zend_Application_Module_Autoloader(array(
                
'namespace' => 'My_',
                    
'basePath'  => APPLICATION_PATH '/library/My_',
                
'resourceTypes' => array(
                        
'forms'=>array('path'=>'Plugins_/',
                    
'namespace'=>'My_Plugins/')
                )
            )
        );
         
var_dump(APPLICATION_PATH);
    }


en el .ini hay.
Código:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

autoloaderNamespaces[] = "Mis_"
resources.frontController.plugins.Primero = "My_Plugins_Primero"
y en el index esta:
Código 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'));



set_include_path(implode(PATH_SEPARATOR, array(
    
realpath(APPLICATION_PATH '/../library'),
    
get_include_path(),
)));

require_once 
'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    
APPLICATION_ENV,
    
APPLICATION_PATH '/configs/application.ini'
);
$application->bootstrap()
            ->
run(); 
y mi carpeta de plugins esta en .

A)-application

B)-libray
B.1-Zend
-library
B.2-MY
B.2.1-Plugins
-Primero.php
C-public


Saludos y espero esta ayudita...segurie probando para dar con la solucion

Última edición por niewpendejo; 07/03/2010 a las 04:32 Razón: Dar mas detalles
  #2 (permalink)  
Antiguo 08/03/2010, 09:48
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Cargar Plugins en Zend framework

El problema es que le dices al autoloader que cargue los plugins que empiecen con Mis_ pero tus clases y plugins estan con My_

Saludos.
  #3 (permalink)  
Antiguo 08/03/2010, 16:13
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Cargar Plugins en Zend framework

Muchas gracias , creo que por ahi estaba el problema , aunque me queda una duda...que cuando hago un var_dump($autoloader), el resultado es el siguiente:

Código:
object(Zend_Application_Module_Autoloader)[8]
  protected '_basePath' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application' (length=99)
  protected '_components' => 
    array
      'My_Model_DbTable' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models/DbTable' (length=114)
      'My_Model_Mapper' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models/mappers' (length=114)
      'My_Form' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/forms' (length=105)
      'My_Model' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models' (length=106)
      'My_Plugin' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/plugins' (length=107)
      'My_Service' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/services' (length=108)
      'My_View_Helper' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/views/helpers' (length=113)
      'My_View_Filter' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/views/filters' (length=113)
  protected '_defaultResourceType' => string 'model' (length=5)
  protected '_namespace' => string 'My' (length=2)
  protected '_resourceTypes' => 
    array
      'dbtable' => 
        array
          'namespace' => string 'My_Model_DbTable' (length=16)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models/DbTable' (length=114)
      'mappers' => 
        array
          'namespace' => string 'My_Model_Mapper' (length=15)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models/mappers' (length=114)
      'form' => 
        array
          'namespace' => string 'My_Form' (length=7)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/forms' (length=105)
      'model' => 
        array
          'namespace' => string 'My_Model' (length=8)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/models' (length=106)
      'plugin' => 
        array
          'namespace' => string 'My_Plugin' (length=9)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/plugins' (length=107)
      'service' => 
        array
          'namespace' => string 'My_Service' (length=10)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/services' (length=108)
      'viewhelper' => 
        array
          'namespace' => string 'My_View_Helper' (length=14)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/views/helpers' (length=113)
      'viewfilter' => 
        array
          'namespace' => string 'My_View_Filter' (length=14)
          'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\application/views/filters' (length=113)


Ademas salen en las demas referencias, por ejemplo como en esta:

'namespace' => string 'My_Form' (length=7)
'path' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\ap plication/forms' (length=105)

No entiendo muy bien si es correcto que salga: 'namespace' => string 'My_Form' (length=7)
, cuando no hay ninguna carpeta My , para los formularios...

Tambien Aparece esto en:

My_Plugin' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\ap plication/plugins'

Y No deberia de ser:

My_Plugin' => string 'C:\Archivos de programa\Apache Software Foundation\Apache2.2\ZendFramework\Acreditacion\li brary/My/Plugins'

saludos
  #4 (permalink)  
Antiguo 08/03/2010, 16:20
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Cargar Plugins en Zend framework

Lo que pasa es que estas viendo el Module Autloader, si quieres que cargue las clases de tu library tienes que decirle al Autoloader de Zend que lo haga por ejemplo:
Código PHP:
Ver original
  1. $autoloader = Zend_Loader_Autoloader::getInstance();
  2. $autoloader->registerNamespace('My_');

Son dos cosas diferentes el Resource Module Autoloader y el Autoloader de Zend como tal.

Saludos.
  #5 (permalink)  
Antiguo 08/03/2010, 16:57
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Cargar Plugins en Zend framework

Ya si que me he perdido con , jajaj, me volvere a mirar el libro , esto de cargar
la clase
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');

Se pone en el index del public, verdad?
  #6 (permalink)  
Antiguo 08/03/2010, 20:31
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Cargar Plugins en Zend framework

Así es, pero tu ya no lo tienes que hacer, ya que en tu application.ini le estas indicando a Zend que namespaces registrar al usar: autoloaderNamespaces[] = "Mis_"

Saludos.
  #7 (permalink)  
Antiguo 09/03/2010, 15:53
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Cargar Plugins en Zend framework

Muchas gracias por tu respuesta...segurire preguntando por aqui porque cada dia surgen dudas y veo que el zend es super extenso y pontente , y supongo que como todo al principio cuesta...saludos

Etiquetas: framework, plugins
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:41.