2016-09-22 2 views
1

Je viens de commencer hier le Zend Framework 3 tutorialZend Framework 3 erreur tutoriel

Mais, at this step:

quand j'avais le module 'album' dans modules.config.php J'ai eu cette erreur suivante:

Zend\ServiceManager\Exception\ServiceNotFoundException 
/var/www/api/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php:133 
A plugin by the name "getServiceLocator" was not found in the plugin manager Zend\Mvc\Controller\PluginManager 
#0 /var/www/api/vendor/zendframework/zend-mvc/src/Controller/PluginManager.php(98): Zend\ServiceManager\AbstractPluginManager->get('getServiceLocat...', NULL) 
#1 /var/www/api/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(258): Zend\Mvc\Controller\PluginManager->get('getServiceLocat...', NULL) 
#2 /var/www/api/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(273): Zend\Mvc\Controller\AbstractController->plugin('getServiceLocat...') 
#3 /var/www/api/module/Album/src/Album/Controller/AlbumController.php(104): Zend\Mvc\Controller\AbstractController->__call('getServiceLocat...', Array) 
#4 /var/www/api/module/Album/src/Album/Controller/AlbumController.php(104): Album\Controller\AlbumController->getServiceLocator() 
#5 /var/www/api/module/Album/src/Album/Controller/AlbumController.php(16): Album\Controller\AlbumController->getAlbumTable() 
#6 /var/www/api/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Album\Controller\AlbumController->indexAction() 
#7 /var/www/api/vendor/zendframework/zend-eventmanager/src/EventManager.php(271): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent)) 
#8 /var/www/api/vendor/zendframework/zend-eventmanager/src/EventManager.php(151): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure)) 
#9 /var/www/api/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(105): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent)) 
#10 /var/www/api/vendor/zendframework/zend-mvc/src/DispatchListener.php(119): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response)) 
#11 /var/www/api/vendor/zendframework/zend-eventmanager/src/EventManager.php(271): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent)) 
#12 /var/www/api/vendor/zendframework/zend-eventmanager/src/EventManager.php(151): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure)) 
#13 /var/www/api/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent)) 
#14 /var/www/api/public/index.php(48): Zend\Mvc\Application->run() 
#15 {main} 

Can quelqu'un m'aider s'il vous plaît, je ne comprends vraiment pas, je suis juste le tuto. Merci!

namespace Album; 

use Zend\Router\Http\Segment; 

return [ 

    'router' => [ 
     'routes' => [ 
      'album' => [ 
       'type' => Segment::class, 
       'options' => [ 
        'route' => '/album[/:action[/:id]]', 
        'constraints' => [ 
         'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 
         'id'  => '[0-9]+', 
        ], 
        'defaults' => [ 
         'controller' => Controller\AlbumController::class, 
         'action'  => 'index', 
        ], 
       ], 
      ], 
     ], 
    ], 

    'view_manager' => [ 
     'template_path_stack' => [ 
      'album' => __DIR__ . '/../view', 
     ], 
    ], 
]; 
+0

J'ai le même problème – RPichioli

+0

@Cochou S'il vous plaît donner votre 'module/Album/config/module.config.php'. –

+0

@AlFonce merci de répondre! Ici: – Cochou

Répondre

0

Dans votre AlbumController classe, vous appelez getServiceLocator(), mais vous ne devriez pas avoir à le faire. Êtes-vous sûr de suivre le tutoriel officiel de ZF3? Il n'y a pas d'appel getServiceLocator() dans ce tutoriel. Vous ne devriez pas avoir à récupérer le gestionnaire de service à partir d'un contrôleur, car vous devriez injecter les services nécessaires dans le contrôleur (c'est la manière ZF3 à faire).

Je vous suggère fortement d'enlever de votre code tout ce qu'il n'est pas dans le tutoriel. Une fois que vous finirai (y compris le en profondeur tutoriel), vous comprendrez pourquoi vous ne devriez pas avoir à appeler une méthode getServiceLocator() de vos contrôleurs ...

0

« view_manager » => [// réglage les vues 'display_not_found_reason' => true, // il contrôle s'il faut afficher les informations détaillées sur l'erreur Page introuvable. « display_exceptions » => true, // définit si vous souhaitez afficher les informations sur une exception non gérée et sa trace de la pile

//*** the two parameters shown above MUST be set to FALSE in production systems, because you don't want the site visitors see the details about errors in you site. 
    ////However, you will still be able to retrieve the detailed information from Apache's error.log file 

    'doctype'     => 'HTML5', 
    'not_found_template'  => 'error/404', //defines the TEMPLATE NAME for the 404 error(it will be searched on template_map) 
    'exception_template'  => 'error/index', //defines the TEMPLATE NAME for the unhandled exception error 
    'template_map' => [ 
     'layout/layout'   => __DIR__ . '/../view/layout/default.phtml', 

     'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',    
     'error/404'    => __DIR__ . '/../view/error/404.phtml', 
     'error/index'    => __DIR__ . '/../view/error/index.phtml', 
    ], 
    'template_path_stack' => [ 
     __DIR__ . '/../view', 
    ], 
], 

Comme vous pouvez le voir sur les lignes ci-dessus, vous avez quelques erreurs sur votre code. Votre imbrication en tant que clé de votre itinéraire dans la clé 'template_path_stack' qui appartient à la clé 'view_manager'. Essayez de changer votre code et bonne chance.