IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MVC PHP Discussion :

Helper qui ne peut pas être chargé


Sujet :

MVC PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de ilalaina
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    341
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Madagascar

    Informations forums :
    Inscription : Mai 2007
    Messages : 341
    Par défaut Helper qui ne peut pas être chargé
    Bonjour à tous.
    Je ne sais pas ce qui m'arrive mais j'ai une aide de vue MyUrl qui marche très bien dans quelques pages et ne marche pas dans d'autres.
    Voilà ce qui est bizarre :
    • J'ai une page1, et une page2.
    • Je navigue dans page1 : aucun problème
    • Ensuite je vais dans page2 et j'obtiens une erreur.
    • Je reviens dans page1 : j'obtiens une erreur.
    • Je vide le cache du navigateur
    • Je reviens sur page1 : l'erreur disparaît
    • Je vais sur page2 : l'erreur réapparaît
    • Je reviens sur page1 : l'erreur réapparaît jusqu'à ce que je revides le cahe de mon navigateur

    J'utilise Firefox 3.6.3.

    Ci-dessous l'erreur :
    Code x : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    object(Zend_Session_Exception)#305 (8) {
      ["_previous":"Zend_Exception":private] => NULL
      ["message":protected] => string(326) "Zend_Session::start() - C:\wamp\www\myrep\myapp\library\Zend\Loader.php(Line:146): Error #2 include_once() [<a href='function.include'>function.include</a>]: Failed opening 'Zend\View\Helper\MyUrl.php' for inclusion (include_path='C:\wamp\www\myrep\myapp\application/../library;C:\wamp\www\myrep\myapp\library;.;C:\php5\pear') Array"
      ["string":"Exception":private] => string(0) ""
      ["code":protected] => int(0)
      ["file":protected] => string(46) "C:\wamp\www\myrep\myapp\library\Zend\Session.php"
      ["line":protected] => int(493)
      ["trace":"Exception":private] => array(7) {
        [0] => array(6) {
          ["file"] => string(56) "C:\wamp\www\myrep\myapp\library\Zend\Session\Namespace.php"
          ["line"] => int(143)
          ["function"] => string(5) "start"
          ["class"] => string(12) "Zend_Session"
          ["type"] => string(2) "::"
          ["args"] => array(1) {
            [0] => bool(true)
          }
        }
        [1] => array(6) {
          ["file"] => string(47) "C:\wamp\www\myrep\myapp\application\Bootstrap.php"
          ["line"] => int(84)
          ["function"] => string(11) "__construct"
          ["class"] => string(22) "Zend_Session_Namespace"
          ["type"] => string(2) "->"
          ["args"] => array(2) {
            [0] => string(3) "myapp"
            [1] => bool(true)
          }
        }
        [2] => array(6) {
          ["file"] => string(78) "C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php"
          ["line"] => int(665)
          ["function"] => string(13) "_initSessions"
          ["class"] => string(9) "Bootstrap"
          ["type"] => string(2) "->"
          ["args"] => array(0) {
          }
        }
        [3] => array(6) {
          ["file"] => string(78) "C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php"
          ["line"] => int(618)
          ["function"] => string(16) "_executeResource"
          ["class"] => string(44) "Zend_Application_Bootstrap_BootstrapAbstract"
          ["type"] => string(2) "->"
          ["args"] => array(1) {
            [0] => string(8) "sessions"
          }
        }
        [4] => array(6) {
          ["file"] => string(78) "C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php"
          ["line"] => int(582)
          ["function"] => string(10) "_bootstrap"
          ["class"] => string(44) "Zend_Application_Bootstrap_BootstrapAbstract"
          ["type"] => string(2) "->"
          ["args"] => array(1) {
            [0] => NULL
          }
        }
        [5] => array(6) {
          ["file"] => string(50) "C:\wamp\www\myrep\myapp\library\Zend\Application.php"
          ["line"] => int(355)
          ["function"] => string(9) "bootstrap"
          ["class"] => string(44) "Zend_Application_Bootstrap_BootstrapAbstract"
          ["type"] => string(2) "->"
          ["args"] => array(1) {
            [0] => NULL
          }
        }
        [6] => array(6) {
          ["file"] => string(38) "C:\wamp\www\myrep\myapp\public\index.php"
          ["line"] => int(28)
          ["function"] => string(9) "bootstrap"
          ["class"] => string(16) "Zend_Application"
          ["type"] => string(2) "->"
          ["args"] => array(0) {
          }
        }
      }
      ["previous":"Exception":private] => NULL
    }
    et ci-dessous le contenu de application_path/views/helpers/MyUrl.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <?php
     
    class Zend_View_Helper_MyUrl extends Zend_View_Helper_Abstract
    {
        function myUrl(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
        {
            $router = Zend_Controller_Front::getInstance()->getRouter();
            return 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' :
                '') . '://' . $_SERVER['HTTP_HOST'] . $router->assemble($urlOptions, $name, $reset, $encode);
        }
    }
    Est-ce que quelqu'un a déjà rencontré ce genre de problème?
    (Les autres View helpers que j'ai créés marchent très bien)

    Merci.

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    178
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 178
    Par défaut
    Hello,

    A vue de nez je dirais que tu as enregistré un Zend_View_Helper_MyUrl en session.

    Ce qu'il faut savoir c'est que quand tu stock un objet en session il est en fait sérialsé par php, lorsque la session est redémarrée via session_start php va tenter de déséraliser les objets et pour ça il faut que la définition de classe soit chargée ou «auto-chargeable».

    Apparemment, lors du session_start ton environnement ne serait plus capable de retrouver le fichier définissant ton helper.

    Tant que l'objet est dans la session tu as l'erreur, si tu vides ta session plus de problème.

  3. #3
    Membre éclairé Avatar de ilalaina
    Homme Profil pro
    Inscrit en
    Mai 2007
    Messages
    341
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Madagascar

    Informations forums :
    Inscription : Mai 2007
    Messages : 341
    Par défaut
    Citation Envoyé par patbator Voir le message
    Hello,

    A vue de nez je dirais que tu as enregistré un Zend_View_Helper_MyUrl en session.
    Non tout ce que j'ai fait c'est enregistrer la session dans le registre.
    Ci dessous le code dans le bootstrap :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    /**
     * Initialisation de la session
     */
    function _initSessions()
    {
    	// On initialise la session
    	$session = new Zend_Session_Namespace('mysess', true);
    	Zend_Registry::set('session', $session);
    	return $session;
    } // End _initSessions
    J'ai réussi à résoudre le problème en enregistrant mes helpers dans une autre répertoire et en utilisant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $view->addHelperPath(APPLICATION_PATH . '/../library/My/Views/Helpers', 'My_Views_Helpers_');
    Je pense que c'est le préfixe des classes (Zend_View_Helper) qui a provoqué l'erreur, mais je ne comprends pas pourquoi sur certaines pages ça marchait et sur d'autres non. Ces erreurs n'apparaissaient que quand je passait sur deux pages spécifiques ???

  4. #4
    Membre expérimenté
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    178
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 178
    Par défaut
    Hello,

    Je maintient qu'au vu de la pile d'exécution remontée dans ton premier message :

    C:\wamp\www\myrep\myapp\library\Zend\Session\Namespace.php
    >>> Zend_Session::start
    C:\wamp\www\myrep\myapp\application\Bootstrap.php
    >>> Zend_Session_Namespace::__construct
    C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php
    >>> Bootstrap::_initSessions
    C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php
    >>> "Zend_Application_Bootstrap_BootstrapAbstract::_executeResource
    C:\wamp\www\myrep\myapp\library\Zend\Application\Bootstrap\BootstrapAbstract.php
    >>> Zend_Application_Bootstrap_BootstrapAbstract::_bootstrap
    C:\wamp\www\myrep\myapp\library\Zend\Application.php
    >>> Zend_Application_Bootstrap_BootstrapAbstract::bootstrap
    C:\wamp\www\myrep\myapp\public\index.php
    >>> Zend_Application::bootstrap

    Il est clair que dans ton process de bootstrap arrive le moment où la session est initialisée et qu'à ce moment là l'autoloader n'arrive pas à loader le helper.

    Je ne sais pas à quel moment tu as rajouté le helperPath mais ton blem est/était forcément lié à la session et au moment où elle est initialisée.

Discussions similaires

  1. Vérification d'un champ qui ne peut pas être vide
    Par mathieu dans le forum Téléchargez
    Réponses: 0
    Dernier message: 03/10/2011, 16h56
  2. [Oracle] L'extension php_oci8 ne peut pas être chargée
    Par ilalaina dans le forum PHP & Base de données
    Réponses: 5
    Dernier message: 19/01/2009, 08h08
  3. Réponses: 2
    Dernier message: 12/12/2007, 18h59
  4. Réponses: 3
    Dernier message: 04/09/2007, 21h44
  5. Réponses: 6
    Dernier message: 03/09/2003, 10h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo