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

Zend Framework PHP Discussion :

Erreur fatale sur appel de Zend_Loader::registerautoload


Sujet :

Zend Framework PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Invité
    Invité(e)
    Par défaut Erreur fatale sur appel de Zend_Loader::registerautoload
    Bonjour à tous ,
    j'ai essai plusieur fois de lancer l'execution de l'exemple de cous de zend de mvc mais ca marche pas il donne cette erreur lors de l'execution de localhost/zf-tutoriel :Fatal error: Call to undefined method Zend_Loader::registerautoload() in C:\xampp\htdocs\zf-tutoriel\index.php on line 11

    et voila le contenu de index.php
    Code : 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
    <?php
    error_reporting(E_ALL|E_STRICT);
    ini_set('display_errors', 1);
    date_default_timezone_set('Europe/Paris');
    // mise en place des répertoires et chargement des classes
    set_include_path('.'
    . PATH_SEPARATOR . './library'
    . PATH_SEPARATOR . './application/models/'
    . PATH_SEPARATOR . get_include_path());
    include "Zend/Loader.php";
    Zend_Loader::registerAutoload();
     
    // Chargement de la configuration
    $config = new Zend_Config_Ini('./application/config.ini', 'general');
    $registry = Zend_Registry::getInstance();
    $registry->set('config', $config);
    // Mise en place de la BDD
    $db = Zend_Db::factory($config->db);
    Zend_Db_Table::setDefaultAdapter($db);
    // setup controller
    $frontController = Zend_Controller_Front::getInstance();
    $frontController->throwExceptions(true);
    $frontController->setControllerDirectory('./application/controllers');
    $frontController->setBaseUrl('/zf-tutoriel');
    Zend_Layout::startMvc(array('layoutPath'=>'./application/layout'));
    // run!
    $frontController->dispatch();
    merci cordialement

  2. #2
    Invité
    Invité(e)
    Par défaut
    Salut,

    Zend_Loader::registerautoload() in C:\xampp\htdocs\zf-tutoriel\index.php on line 11
    C'est d'ailleurs bizarre qu'il soit signalé en minuscule dans ton erreur et pas dans ton code.

    Es-tu sûr que c'est bien le code que tu as testé??

  3. #3
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    je suis sur que le code que le code saisie c'est le meme que je cite au dessus

    je sais pas ou le probleme

    Merci D'avance

  4. #4
    Invité
    Invité(e)
    Par défaut
    Le problème vient du fait que ta méthode registerAutoload n'est pas reconnue.

    Est-ce que tu pourrais afficher également le contenu de Loader.php et vérifier que cette méthode est bien avec un A majuscule?

  5. #5
    Invité
    Invité(e)
    Par défaut
    Bonjour ,
    j'ai trouver que le fichier loader.php leur emplacement dans le C:\xampp\htdocs\zf-tutoriel\library\Zend et voila leur leur contenu :
    Code : 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
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    <?php
    /**
     * Zend Framework
     *
     * LICENSE
     *
     * This source file is subject to the new BSD license that is bundled
     * with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://framework.zend.com/license/new-bsd
     * If you did not receive a copy of the license and are unable to
     * obtain it through the world-wide-web, please send an email
     * to license@zend.com so we can send you a copy immediately.
     *
     * @category   Zend
     * @package    Zend_Loader
     * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
     * @license    http://framework.zend.com/license/new-bsd     New BSD License
     */
     
    /**
     * Zend_Exception
     */
    require_once 'Zend/Exception.php';
     
    /**
     * Static methods for loading classes and files.
     *
     * @category   Zend
     * @package    Zend_Loader
     * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
     * @license    http://framework.zend.com/license/new-bsd     New BSD License
     */
     
    class Zend_Loader
    {
        /**
         * Loads a class from a PHP file.  The filename must be formatted
         * as "$class.php".
         *
         * If $dirs is a string or an array, it will search the directories
         * in the order supplied, and attempt to load the first matching file.
         *
         * If $dirs is null, it will split the class name at underscores to
         * generate a path hierarchy (e.g., "Zend_Example_Class" will map
         * to "Zend/Example/Class.php").
         *
         * If the file was not found in the $dirs, or if no $dirs were specified,
         * it will attempt to load it from PHP's include_path.
         *
         * @param string $class      - The full class name of a Zend component.
         * @param string|array $dirs - OPTIONAL Either a path or an array of paths
         *                             to search.
         * @return void
         * @throws Zend_Exception
         */
        public static function loadClass($class, $dirs = null)
        {
            if (class_exists($class, false) || interface_exists($class, false)) {
                return;
            }
     
            if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
                throw new Zend_Exception('Directory argument must be a string or an array');
            }
            if (null === $dirs) {
                $dirs = array();
            }
            if (is_string($dirs)) {
                $dirs = (array) $dirs;
            }
     
            // autodiscover the path from the class name
            $path = str_replace('_', DIRECTORY_SEPARATOR, $class);
            if ($path != $class) {
                // use the autodiscovered path
                $dirPath = dirname($path);
                if (0 == count($dirs)) {
                    $dirs = array($dirPath);
                } else {
                    foreach ($dirs as $key => $dir) {
                        $dir = rtrim($dir, '\\/');
                        $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
                    }
                }
                $file = basename($path) . '.php';
            } else {
                $file = $class . '.php';
            }
     
            self::loadFile($file, $dirs, true);
     
            if (!class_exists($class, false) && !interface_exists($class, false)) {
                throw new Zend_Exception("File \"$file\" was loaded but class \"$class\" was not found in the file");
            }
        }
     
        /**
         * Loads a PHP file.  This is a wrapper for PHP's include() function.
         *
         * $filename must be the complete filename, including any
         * extension such as ".php".  Note that a security check is performed that
         * does not permit extended characters in the filename.  This method is
         * intended for loading Zend Framework files.
         *
         * If $dirs is a string or an array, it will search the directories
         * in the order supplied, and attempt to load the first matching file.
         *
         * If the file was not found in the $dirs, or if no $dirs were specified,
         * it will attempt to load it from PHP's include_path.
         *
         * If $once is TRUE, it will use include_once() instead of include().
         *
         * @param  string        $filename
         * @param  string|array  $dirs - OPTIONAL either a path or array of paths
         *                       to search.
         * @param  boolean       $once
         * @return mixed
         * @throws Zend_Exception
         */
        public static function loadFile($filename, $dirs = null, $once = false)
        {
            // security check
            if (preg_match('/[^a-z0-9\-_.]/i', $filename)) {
                throw new Zend_Exception('Security check: Illegal character in filename');
            }
     
            /**
             * Determine if the file is readable, either within just the include_path
             * or within the $dirs search list.
             */
            $filespec = $filename;
            if (empty($dirs)) {
                $dirs = null;
            }
            if ($dirs === null) {
                $found = self::isReadable($filespec);
            } else {
                foreach ((array)$dirs as $dir) {
                    $filespec = rtrim($dir, '\\/') . DIRECTORY_SEPARATOR . $filename;
                    $found = self::isReadable($filespec);
                    if ($found) {
                        break;
                    }
                }
            }
     
            /**
             * Throw an exception if the file could not be located
             */
            if (!$found) {
                throw new Zend_Exception("File \"$filespec\" was not found");
            }
     
            /**
             * Attempt to include() the file.
             *
             * include() is not prefixed with the @ operator because if
             * the file is loaded and contains a parse error, execution
             * will halt silently and this is difficult to debug.
             *
             * Always set display_errors = Off on production servers!
             */
            if ($once) {
                return include_once $filespec;
            } else {
                return include $filespec ;
            }
        }
     
        /**
         * Returns TRUE if the $filename is readable, or FALSE otherwise.
         * This function uses the PHP include_path, where PHP's is_readable()
         * does not.
         *
         * @param string   $filename
         * @return boolean
         */
        public static function isReadable($filename)
        {
            if (is_readable($filename)) {
                return true;
            }
     
            $path = get_include_path();
            $dirs = explode(PATH_SEPARATOR, $path);
     
            foreach ($dirs as $dir) {
                // No need to check against current dir -- already checked
                if ('.' == $dir) {
                    continue;
                }
     
                if (is_readable($dir . DIRECTORY_SEPARATOR . $filename)) {
                    return true;
                }
            }
     
            return false;
        }
     
        /**
         * spl_autoload() suitable implementation for supporting class autoloading.
         *
         * Attach to spl_autoload() using the following:
         * <code>
         * spl_autoload_register(array('Zend_Loader', 'autoload'));
         * </code>
         * 
         * @param string $class 
         * @return string|false Class name on success; false on failure
         */
        public static function autoload($class)
        {
            try {
                self::loadClass($class);
                return $class;
            } catch (Exception $e) {
                return false;
            }
        }
    }
    Merci de m'aider
    Dernière modification par julp ; 21/09/2008 à 17h24.

  6. #6
    Invité
    Invité(e)
    Par défaut
    Et bien voilà.

    La méthode registerAutoload() n'existe pas dans la classe Zend_loader...

    Quelle version du framework zend as-tu?

    Je viens de télécharger la version 1.6.1 et je retrouve bien cette méthode dans le fichier Loader.php.

    http://framework.zend.com/releases/Z...work-1.6.1.zip


    Code : 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
     
        /**
         * Register {@link autoload()} with spl_autoload()
         *
         * @param string $class (optional)
         * @param boolean $enabled (optional)
         * @return void
         * @throws Zend_Exception if spl_autoload() is not found
         * or if the specified class does not have an autoload() method.
         */
        public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
        {
            if (!function_exists('spl_autoload_register')) {
                require_once 'Zend/Exception.php';
                throw new Zend_Exception('spl_autoload does not exist in this PHP installation');
            }
     
            self::loadClass($class);
            $methods = get_class_methods($class);
            if (!in_array('autoload', (array) $methods)) {
                require_once 'Zend/Exception.php';
                throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
            }
     
            if ($enabled === true) {
                spl_autoload_register(array($class, 'autoload'));
            } else {
                spl_autoload_unregister(array($class, 'autoload'));
            }

Discussions similaires

  1. [AC-2010] erreur 3085 sur appel requete avec fonction
    Par ZargosLord dans le forum VBA Access
    Réponses: 13
    Dernier message: 21/11/2011, 07h39
  2. Erreur OLE sur appel Javascript dans TWebBrowser
    Par 2nd Floor dans le forum Débuter
    Réponses: 8
    Dernier message: 21/09/2011, 15h49
  3. Erreur Thread sur Appel dans DLL
    Par Danyel dans le forum VB.NET
    Réponses: 10
    Dernier message: 27/10/2008, 23h57
  4. Erreur 404 sur appel de vues dans tuto de Rob
    Par *.Har(d)t dans le forum MVC
    Réponses: 16
    Dernier message: 10/07/2007, 20h06
  5. [ByRef Error] Erreur Bizarre sur appel de sub
    Par |DUCATI| DesMo dans le forum VBA Access
    Réponses: 1
    Dernier message: 21/05/2007, 11h10

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