Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Oui,
a tu une contrainte particulière pour passer par du xml?
Hors ligne
j'ai fait pareil avec un fichier php.
return array( array( 'label' => 'Accueil', 'module' => 'application', 'controller' => 'index', 'action' => 'index', 'order' => -100 ) );
Mais exactement la même erreur.
Fatal error: Uncaught exception 'Zend\Navigation\Exception\DomainException' with message 'Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\Mvc\Router\RouteStackInterface instance is composed' in C:\wamp\library\Zend\Navigation\Page\Mvc.php on line 205
( ! ) Zend\Navigation\Exception\DomainException: Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\Mvc\Router\RouteStackInterface instance is composed in C:\wamp\library\Zend\Navigation\Page\Mvc.php on line 205
:-(
au cas ou je donne l'archi de mon projet
/formation
/configs
navigation.php
navigation.xml
site.php(config appli)
/modules
/Application
/config
autoloaders.php
module.php
/controllers
/views
/public
Hors ligne
non je n'ai pas de contrainte particulière, je peux passer par du php. C'était pour essayer et être moins bête mdr.
Hors ligne
je dois m'absenter , je dois m'occuper de ma fille. Je reviens au plus vite.
Merci d'avance.
Hors ligne
Ok, donc si tu passe par un tableau php,
bah je te conseil le get started pour démarrer :
http://framework.zend.com/manual/curren … ation.html
en passant par la factory tu devrais t'en sortir
Dernière modification par flobrflo (11-02-2015 17:43:10)
Hors ligne
j'ai rajouté la clé navigation dans la config de mon module
<?php //return [ // // /* Définition des routes. */ // 'router' => [ // 'routes' => [ // 'default' => [ // 'type' => 'Segment', // 'options' => [ // 'route' => '/:module/:controller/:action', // ], // ], // ], // ], // // // /* Définition des contrôleurs du Module. */ // 'controllers' => [ // 'invokables' => [ // 'Index' => 'Application\Controller\Index', // ], // ], // // /* Configuration de la gestion des vues. */ // 'view_manager' => [ // 'doctype' => 'HTML5', // //'layout' => 'skeleton', // //'not_found_template' => 'notfound', // 'not_found_template' => 'error/404', // // /* Configuration du chargeur de templates par mapping. */ // 'template_map' => [ // // 'skeleton' => "{$sPath}/views/skeleton.phtml", // // 'notfound' => "{$sPath}/views/error-404.phtml", // 'layout/layout' => __DIR__ . '/../views/layout/layout.phtml', // 'application/index/index' => __DIR__ . '/../views/application/index/index.phtml', // 'error/404' => __DIR__ . '/../views/error/404.phtml', // ], // // /* Configuration du chargeur TemplatePathStack. */ // 'template_path_stack' => [ // "{$sPath}/views", // ], // ], //]; /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Segment', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index', ), ), ), // The following is a route to simplify getting started creating // new controllers and actions without needing to create a new // module. Simply drop new controllers in, and you can access them // using the path /application/:controller/:action 'application' => array( 'type' => 'Segment', 'options' => array( 'route' => '/application', 'defaults' => array( '__NAMESPACE__' => 'Application\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => array( 'type' => 'Segment', 'options' => array( 'route' => '/[:controller[/:action]]', 'constraints' => array( 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( ), ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Application\Controller\Index' => 'Application\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'layout/layout' => __DIR__ . '/../views/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../views/application/index/index.phtml', 'error/404' => __DIR__ . '/../views/error/404.phtml', 'error/index' => __DIR__ . '/../views/error/index.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), );
mon fichier navigation php
return array( 'navigation' => array( 'default' => array( array( 'label' => 'Home', 'route' => 'home', ), array( 'label' => 'Accueil', 'route' => 'application', 'pages' => array( array( 'label' => 'home', 'route' => 'application', 'action' => 'index', ), ), ), ), ), );
et mon render dans mon layout :
echo $this->navigation('navigation') ->menu() ->setMinDepth(0) ->setMaxDepth(0) ->setUlClass('nav');
mais j'ai une erreur et je comprends pas pourquoi
Fatal error: Uncaught exception 'Zend\Navigation\Exception\InvalidArgumentException' with message 'Could not find navigation configuration key' in C:\wamp\library\Zend\ServiceManager\ServiceManager.php on line 909
( ! ) Zend\Navigation\Exception\InvalidArgumentException: Could not find navigation configuration key in C:\wamp\library\Zend\Navigation\Service\AbstractNavigationFactory.php on line 58
je sais pas si je peux revenir ce soir au pire je suis la demain a partir de 9h
merci beaucoup
Hors ligne
oula c'est bon cela fonctionne je pensais qu'il fallait absolument un fichier extérieur à la configuration.
Cool merci beaucoup, au bout d'un moment on voit plus rien.
Bonne continuation
Hors ligne
Heu j'aurais juste une petite question le code que j'ai mis est seulement pour le module, cela veut dire qu'il faut que je fasse une clé différente pour chaque module et pour chaque layout de ces derniers ?
merci d'avance.
Hors ligne
j'ai ajouté un module contact.
voici sa config :
[lang=php]<?php /** * */ return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Segment', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'index', ), ), ), 'contact' => array( 'type' => 'Segment', 'options' => array( 'route' => '/contact', 'defaults' => array( '__NAMESPACE__' => 'Contact\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => array( 'type' => 'Segment', 'options' => array( 'route' => '/[:controller[/:action]]', 'constraints' => array( 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( ), ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Contact\Controller\Index' => 'Contact\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'contact/index/add' => __DIR__ . '/../views/contact/index/add.phtml', 'contact/index/associate' => __DIR__ . '/../views/contact/index/associate.phtml', 'contact/index/associations-list' => __DIR__ . '/../views/contact/index/associations-list.phtml', 'contact/index/delete' => __DIR__ . '/../views/contact/index/delete.phtml', 'contact/index/dissociate' => __DIR__ . '/../views/contact/index/dissociate.phtml', 'contact/index/edit' => __DIR__ . '/../views/contact/index/edit.phtml', 'contact/index/index' => __DIR__ . '/../views/contact/index/index.phtml', 'contact/index/list' => __DIR__ . '/../views/contact/index/list.phtml', 'contact/index/sheet' => __DIR__ . '/../views/contact/index/sheet.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), 'navigation' => array( 'default' => array( array( 'label' => 'Contact', 'route' => 'contact', 'pages' => array( array( 'label' => 'Home contact', 'route' => 'contact', 'action' => 'index', ), array( 'label' => 'Liste', 'route' => 'contact', 'action' => 'list', ), array( 'label' => 'Ajout', 'route' => 'contact', 'action' => 'add', ), array( 'label' => 'Modifier', 'route' => 'contact', 'action' => 'edit', ), array( 'label' => 'Supprimer', 'route' => 'contact', 'action' => 'delete', ), array( 'label' => 'Associer', 'route' => 'contact', 'action' => 'associate', ), array( 'label' => 'Désassocier', 'route' => 'contact', 'action' => 'dissociate', ), array( 'label' => 'Fiche', 'route' => 'contact', 'action' => 'sheet', ), array( 'label' => 'Liste des associations', 'route' => 'contact', 'action' => 'link-list', ), ), ), ), ), );
Le label contact se rajoute bien par contre je ne comprends pas quand je clique dessus, je tombe "The requested URL /contact/ was not found on this server."
Je comprends pas pourquoi.
Sinon le module est bien chargé.
pourriez vous m'aider s'il vous plaît ?
merci d'avance.
Dernière modification par yoann92 (11-02-2015 23:50:05)
Hors ligne
Hello
déjà hésite pas à éditer tes messages, c'est plus clair qu'en avoir 5 d'affilés ^^
Pour ta première question, ta navigation tu la mets dans un seul module ^^
Personnellement je le mettrais dans application ou dans ton module principal correspondant au cœur de ton site.
Tu a une petite erreur dans ta route : /contact est "segment" donc elle attend un paramètre variable, si tu veux qu'il n'y ai que le texte prédéfini il faut paramétrer la route comme litteral
Hors ligne
Coucou flobrflo,
merci pour ta réponse.
du coup j'ai ajouté le bout de code navigation du module contact au module application
config module application
[lang=php]<?php /** * */ return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Segment', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index', ), ), ), 'application' => array( 'type' => 'Segment', 'options' => array( 'route' => '/application', 'defaults' => array( '__NAMESPACE__' => 'Application\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => array( 'type' => 'Segment', 'options' => array( 'route' => '/[:controller[/:action]]', 'constraints' => array( 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( ), ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Application\Controller\Index' => 'Application\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'layout/layout' => __DIR__ . '/../views/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../views/application/index/index.phtml', 'error/404' => __DIR__ . '/../views/error/404.phtml', 'error/index' => __DIR__ . '/../views/error/index.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), 'navigation' => array( 'default' => array( array( 'label' => 'Accueil', 'route' => 'home', ), ), 'contact' => array( array( 'label' => 'Contact', 'route' => 'segment', 'pages' => array( array( 'label' => 'Home contact', 'route' => 'contact', 'action' => 'index', ), array( 'label' => 'Liste', 'route' => 'contact', 'action' => 'list', ), array( 'label' => 'Ajout', 'route' => 'contact', 'action' => 'add', ), array( 'label' => 'Modifier', 'route' => 'contact', 'action' => 'edit', ), array( 'label' => 'Supprimer', 'route' => 'contact', 'action' => 'delete', ), array( 'label' => 'Associer', 'route' => 'contact', 'action' => 'associate', ), array( 'label' => 'Désassocier', 'route' => 'contact', 'action' => 'dissociate', ), array( 'label' => 'Fiche', 'route' => 'contact', 'action' => 'sheet', ), array( 'label' => 'Liste des associations', 'route' => 'contact', 'action' => 'link-list', ), ), ), ), ), );
config module contact :
[lang=php]<?php /** * */ return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Segment', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'index', ), ), ), 'contact' => array( 'type' => 'Segment', 'options' => array( 'route' => '/contact', 'defaults' => array( '__NAMESPACE__' => 'Contact\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => array( 'type' => 'Segment', 'options' => array( 'route' => '/[:controller[/:action]]', 'constraints' => array( 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( ), ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Contact\Controller\Index' => 'Contact\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'contact/index/add' => __DIR__ . '/../views/contact/index/add.phtml', 'contact/index/associate' => __DIR__ . '/../views/contact/index/associate.phtml', 'contact/index/associations-list' => __DIR__ . '/../views/contact/index/associations-list.phtml', 'contact/index/delete' => __DIR__ . '/../views/contact/index/delete.phtml', 'contact/index/dissociate' => __DIR__ . '/../views/contact/index/dissociate.phtml', 'contact/index/edit' => __DIR__ . '/../views/contact/index/edit.phtml', 'contact/index/index' => __DIR__ . '/../views/contact/index/index.phtml', 'contact/index/list' => __DIR__ . '/../views/contact/index/list.phtml', 'contact/index/sheet' => __DIR__ . '/../views/contact/index/sheet.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), );
Par je vois pas ce que tu veux dire pour le type "segment" car dans le module application j'ai /application.
Pourrais tu m'aiguiller s'il te plaît ?
La j'ai que Accueil dans mon menu.
et oui je ferai plus 5 messages d'affilés :-)
merci d'avance.
Hors ligne
Je parle de ta route /contact
qui n'attends pas de paramètre derrière. ton url est bien
www.monsite.com/contact.
soit dit en passant tu a rajouté une child_route à contact qui permettrais de faire :
www.monsite.com/contact/z-f.fr/askto (avec /:controller/:action de ta child_route default)
Alors si le routing est nouveau pour toi, il y a plein de post du sujet sur le forum et la doc et très complète
Hors ligne
ok merci flobrflo je regarde je te tiens au courant :-)
oui nouveau dans zf2.
Dernière modification par yoann92 (12-02-2015 10:02:02)
Hors ligne
Salut, c'est pas gênant d'avoir une route de type segment lorsqu'il n'y a pas de paramètre ça fonctionne quand même, c'est juste un peu plus lent.
J'ai édité pour mettre la coloration syntaxique, tu peux la mettre avec [lang=php] juste après ta balise code.
Pour la configuration de la navigation tu n'es pas obligé de mettre tout dans le même module. A partir du moment où tu définies des dépendances entre tes modules tu peux mettre ce qui concerne ton module dans son propre fichier de conf car tout est mergé à la fin. Si tu fais les choses bien ça pose pas plus de problèmes que ça.
Pour revenir sur tes routes le mieux c'est de définir le plus de routes Literal possible et lorsque tu as des paramètres dans l'url passer par du type Segment (les url dynamiques sont représentées par :mavariable et entre [] quand c'est optionnel). Donc ton /application tu peux le mettre en type Literal, ta route home aussi (/), contact même chose mais ça ne résoudra pas ton problème dans tous les cas.
Dans la configuration de ton module contact tu peux retirer la route home elle est déjà dans le module application et tu ne peux pas avoir 2 routes avec la même url de toute façon, c'est le module chargé en dernier qui écrase les autres donc tu vas te retrouver avec des comportements bizarres (si ça ne plante pas). Déjà avec ça tu devrais pouvoir avancer un peu.
Et essai d'être un peu plus rigoureux et de bien comprendre ce que tu fais parce qu'on voit bien que tu comprends pas vraiment ce que tu fais du coup c'est pas cohérent et ça donne l'impression que c'est fait à l'arrache .
Hors ligne
merci Orkin tout à fait d'accord avec toi. J'en prends bien note. Je continue de bouquiner afin de mieux comprendre. Merci en tout cas
Hors ligne
je suis en train de bouquiner sur un site Jobeet
ce que je pense comprendre :
-Type de route :
- segment : /(module/[:controller[/:action]]]
- literal : on définit module/controller/action
j'avoue j'arrive pas à voir la diff.
ensuite ce que je cherche à faire
mon module application est mon point d'entrée donc www.site.fr
après mes différents module j'aimerais que ce soit www.site.fr/module/controller/action/params (pour l'édition par exemple ou la suppresion)
et dernier point un truc que je comprends pas :
[lang=php] $route = Literal::factory(array( 'route' => '/news', 'defaults' => array( 'controller' => 'Application\Controller\IndexController', 'action' => 'read' ), ));
la a quoi correspond la route s'il vous plaît ?
merci d'avance.
Hors ligne
Hé bien ta route
- segment : /(module/[:controller[/:action]]]
si tu met pour une route d'un module nommé monModule :
[lang=php] monModule/titi/tata // marchera monModule/toto/titi // marchera monAutreModule/toto/titi //Renverra une 404
- literal : on définit module/controller/action
si tu met pour une route d'un module nommé monModule/MonController/MonAction :
[lang=php] monModule/titi/tata // Renverra une 404 monModule/toto/titi // Renverra une 404 monAutreModule/toto/titi //Renverra une 404 monModule/MonController/MonAction // Marchera
Est ce plus clair ?
Une literal ne marche que pour une route exprimé clairement dans la configuration,
une route Segment te permet de valider des routes exprimés quand elle suivent un pattern bien précis.
POur une page news :
/news te renvoie à l'accueil de toute les news
/news/1 te renverrais à la page de la news 1 pour lire editer etc... Mais ! pour ce paramètre tu as besoin d'une route segment te permettant de valider cette route;
Voici du code d'un de mes modules :
[lang=php] 'backoffice' => array( 'type' => 'Literal', 'options' => array( 'route' => '/backoffice', 'defaults' => array( 'controller' => 'Admin\Controller\Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'rights' => array( 'type' => 'Segment', 'options' => array( 'route' => '/rights', 'defaults' => array( 'controller' => 'Admin\Controller\Rights', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'updateRole' => array( 'type' => 'Segment', 'options' => array( 'route' => '/update-role[/:id]', 'defaults' => array( 'controller' => 'Admin\Controller\Rights', 'action' => 'updateRole' ) ) ), 'deleteRole' => array( 'type' => 'Segment', 'options' => array( 'route' => '/delete-role[/:id]', 'defaults' => array( 'controller' => 'Admin\Controller\Rights', 'action' => 'deleteRole' ) ) ), 'addRole' => array( 'type' => 'Segment', 'options' => array( 'route' => '/add-role', 'defaults' => array( 'controller' => 'Admin\Controller\Rights', 'action' => 'addRole' ) ) ), ), ), ), ), //other config here
ici tu peux voir j'ai une route literal qui m'emmene à la page backoffice
tu peu voir aussi que grâce à ça
[lang=php] 'may_terminate' => true, 'child_routes' => array(
je déclare des route enfant qui prennent mes paramètre dans des routes segment.
Et regarde bien les action des contrôleurs qui sont appelés ce ne sont pas les mêmes ! Même si le contrôleur est le même (et il pourrai changer si je le voulais)
Dernière modification par JGreco (12-02-2015 13:53:07)
Hors ligne
bonjour JGreco,
merci pour ta réponse.
du coup literal rend "moins souple" et plus précis le routing ?
car dans mon projet à part le module application renvoie sur la home donc ww.site.fr, sinon les autres seront de type www.site.fr/module/controller/action , de ce que disait Orkin il est préférable d'utiliser le literal.
après dans cette exemple je comprends pas ce que définit la route ( module ? controller ? action ?)
[lang=php] $route = Literal::factory(array( 'route' => '/news', 'defaults' => array( 'controller' => 'Application\Controller\IndexController', 'action' => 'read' ), ));
merci d'avance.
Hors ligne
Dans ton exemple,
tu irait a la route www.site.fr/news
Cette route ferait appel a ton controlleur Application\Controller\IndexController
Dans ce controlleur tu doit avoir une méthode
[lang=php] public function readAction(){}
Et tu doit avoir une vue dans Application/view/index qui porte le meme nom que le controlleur donc index.phtml
EDIT :
Je pense que tu es parti un peu trop vite en besogne sur le framework a vouloir déjà sortir des sentiers battus quand tu ne maîtrise pas totalement les principes de base, je t'encourage à suivre le tutoriel sur les albums tu en apprendras beaucoup. D'autre part, les questions sur le forum pourraient également t'aider à progresser.
Dernière modification par JGreco (12-02-2015 13:59:25)
Hors ligne
merci JGreco,
la je vais plus toucher à mon module application, comme c'est pour la home.
Je vais faire des test sur mon module Contact, je réponds au plus vite ce qu'il en est.
Le fait de manipuler m'aidera à comprendre....j'espère.
Je reviens. Merci.
Hors ligne
Je ne peu que te conseiller de démarrer avec la doc, ces notions sont très bien expliqué et l'exemple Album du "Get Started" te permettra de comprendre toutes les mécaniques de base du framework.
Hors ligne
merci flobrflo, je vais tester je reviens vers vous. en tout c'est gentil de m'aider.
J'ai du mal pour la simple et bonne raison que j'étais sur du magento pendant plus d'un an et ma formation zend remonte à plus du coup j'y vois pas clair du tout lol.
A tout à l'heure.
Hors ligne
j'ai fait des tests et la cela coince un peu, je comprends pas trop pourquoi.
[lang=php] <?php /** * */ return array( 'router' => array( 'routes' => array( 'contact' => array( 'type' => 'Literal', 'options' => array( 'route' => '/contact', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'liste', ), ), 'may_terminate' => true, 'child_routes' => array( 'add' => array( 'type' => 'Literal', 'options' => array( 'route' => '/add', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'add', ), ), 'edit' => array( 'type' => 'Segment', 'options' => array( 'route' => '/edit[/:id]', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'edit' ) ) ), 'delete' => array( 'type' => 'Segment', 'options' => array( 'route' => '/delete[/:id]', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'delete' ) ) ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Contact\Controller\Index' => 'Contact\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'contact/index/add' => __DIR__ . '/../views/contact/index/add.phtml', 'contact/index/associate' => __DIR__ . '/../views/contact/index/associate.phtml', 'contact/index/associations-list' => __DIR__ . '/../views/contact/index/associations-list.phtml', 'contact/index/delete' => __DIR__ . '/../views/contact/index/delete.phtml', 'contact/index/dissociate' => __DIR__ . '/../views/contact/index/dissociate.phtml', 'contact/index/edit' => __DIR__ . '/../views/contact/index/edit.phtml', 'contact/index/index' => __DIR__ . '/../views/contact/index/index.phtml', 'contact/index/list' => __DIR__ . '/../views/contact/index/list.phtml', 'contact/index/sheet' => __DIR__ . '/../views/contact/index/sheet.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), 'navigation' => array( 'type' => 'literal', 'default' => array( array( 'label' => 'Contact', 'route' => 'contact', 'pages' => array( array( 'label' => 'Home contact', 'route' => 'contact', 'action' => 'index', ), array( 'label' => 'Liste', 'route' => 'contact', 'action' => 'list', ), array( 'label' => 'Ajout', 'route' => 'contact', 'action' => 'add', ), array( 'label' => 'Modifier', 'route' => 'contact', 'action' => 'edit', ), array( 'label' => 'Supprimer', 'route' => 'contact', 'action' => 'delete', ), array( 'label' => 'Associer', 'route' => 'contact', 'action' => 'associate', ), array( 'label' => 'Désassocier', 'route' => 'contact', 'action' => 'dissociate', ), array( 'label' => 'Fiche', 'route' => 'contact', 'action' => 'sheet', ), array( 'label' => 'Liste des associations', 'route' => 'contact', 'action' => 'link-list', ), ), ), ), ), );
J'ai le même controller pour toutes les actions.
je définit en litéral mon module contact, et je définit en segment quand je peut avec des params.
pour faire www.site.fr/contact.
Ensuite je lui définit par sa vue par défaut : www.site.fr/contact/index/liste
et je tombe sur une 404 : The requested URL /contact/index/liste was not found on this server.
Pourriez vous m'expliquer s'il vous plaît ?
merci d'avance.
Hors ligne
En fait la tu a pas de route index.
tu a:
contact/
contact/add
contact/delete/id
contact/edit/id
c'est donc normal
Hors ligne
mmm j'avais un doute justement lol. Ok je vais retester.
Merci
je commence un peu mieux à comprendre, mais j'arrive toujours sur une 404
[lang=php] <?php /** * */ return array( 'router' => array( 'routes' => array( 'contact' => array( 'type' => 'Literal', 'options' => array( 'route' => '/contact', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'liste', ), ), 'may_terminate' => true, 'child_routes' => array( 'index' => array( 'type' => 'Segment', 'options' => array( 'route' => '/index[/:action][/:id]', 'constraints' => array( 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'id' => '[0-9]+', ), 'defaults' => array( '__NAMESPACE__' => 'Contact\Controller', 'controller' => 'Contact\Controller\Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'add' => array( 'type' => 'Literal', 'options' => array( 'route' => '/add', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'add', ), ), 'edit' => array( 'type' => 'Segment', 'options' => array( 'route' => '/edit[/:id]', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'edit' ) ) ), 'delete' => array( 'type' => 'Segment', 'options' => array( 'route' => '/delete[/:id]', 'defaults' => array( 'controller' => 'Contact\Controller\Index', 'action' => 'delete' ) ) ), ), ), ), ), ), ), ), 'service_manager' => array( 'abstract_factories' => array( 'Zend\Cache\Service\StorageCacheAbstractServiceFactory', 'Zend\Log\LoggerAbstractServiceFactory', ), 'aliases' => array( 'translator' => 'MvcTranslator', ), 'factories' => array( 'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', ), ), 'translator' => array( 'locale' => 'fr_FR', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'Contact\Controller\Index' => 'Contact\Controller\Index' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'contact/index/add' => __DIR__ . '/../views/contact/index/add.phtml', 'contact/index/associate' => __DIR__ . '/../views/contact/index/associate.phtml', 'contact/index/associations-list' => __DIR__ . '/../views/contact/index/associations-list.phtml', 'contact/index/delete' => __DIR__ . '/../views/contact/index/delete.phtml', 'contact/index/dissociate' => __DIR__ . '/../views/contact/index/dissociate.phtml', 'contact/index/edit' => __DIR__ . '/../views/contact/index/edit.phtml', 'contact/index/index' => __DIR__ . '/../views/contact/index/index.phtml', 'contact/index/list' => __DIR__ . '/../views/contact/index/list.phtml', 'contact/index/sheet' => __DIR__ . '/../views/contact/index/sheet.phtml', ), 'template_path_stack' => array( __DIR__ . '/../views', ), ), // Placeholder for console routes 'console' => array( 'router' => array( 'routes' => array( ), ), ), 'navigation' => array( 'type' => 'literal', 'default' => array( array( 'label' => 'Contact', 'route' => 'contact', 'pages' => array( array( 'label' => 'Home contact', 'route' => 'contact', 'action' => 'index', ), array( 'label' => 'Liste', 'route' => 'contact', 'action' => 'list', ), array( 'label' => 'Ajout', 'route' => 'contact', 'action' => 'add', ), array( 'label' => 'Modifier', 'route' => 'contact', 'action' => 'edit', ), array( 'label' => 'Supprimer', 'route' => 'contact', 'action' => 'delete', ), array( 'label' => 'Associer', 'route' => 'contact', 'action' => 'associate', ), array( 'label' => 'Désassocier', 'route' => 'contact', 'action' => 'dissociate', ), array( 'label' => 'Fiche', 'route' => 'contact', 'action' => 'sheet', ), array( 'label' => 'Liste des associations', 'route' => 'contact', 'action' => 'link-list', ), ), ), ), ), );
Pourtant je lui spécifie le bon namespace, là je vois pas trop.
Merci d'avance.
Dernière modification par yoann92 (12-02-2015 14:57:22)
Hors ligne