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 :

[ZF 2.0] Creer un 2 eme controleur dans un meme module


Sujet :

Zend Framework PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Avatar de Jcpan
    Inscrit en
    Août 2008
    Messages
    542
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 542
    Par défaut [ZF 2.0] Creer un 2 eme controleur dans un meme module
    Bonjour

    Je debute avec zend 2.0, pour ceci j'ai telecharger zend studio la version beta qui peut fournir la squelette du'une apllication. apres la creation tout s'affiche bien j'ai la page principale contenant des informations sur le framework, cependant j'ai voulu créer un deusieme controlleur et c'est ou je plante. dans la version 1 si on crée un 2eme controlleur dans le module default nommé TestController avec une action index, on accede à celui ainsi monurl.com/test, sauf que sur la version 2.0 je n'arrive pas à l'afficher. vopici un imprime ecran

    et voici le fichier TestZendController.php generé par zend studio

    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
    <?php
     
    namespace Application\Controller;
     
    use Zend\Mvc\Controller\AbstractActionController;
    use Zend\View\Model\ViewModel;
     
    /**
     * TestZendController
     *
     * @author
     *
     * @version
     *
     */
    class TestZendController extends AbstractActionController {
    	/**
    	 * The default action - show the home page
    	 */
    	public function indexAction() {
    		// TODO Auto-generated TestZendController::indexAction() default action
    		return new ViewModel ();
    	}
    }
    voici le fichier module.config.php aussi genré par Zend studio

    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
    <?php
    /**
     * Zend Framework (http://framework.zend.com/)
     *
     * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
     * @copyright Copyright (c) 2005-2012 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' => 'Zend\Mvc\Router\Http\Literal',
                    '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'    => 'Literal',
                    '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(
            'factories' => array(
                'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
            ),
        ),
        'translator' => array(
            'locale' => 'en_US',
            'translation_patterns' => array(
                array(
                    'type'     => 'gettext',
                    'base_dir' => __DIR__ . '/../language',
                    'pattern'  => '%s.mo',
                ),
            ),
        ),
        'controllers' => array(
            'invokables' => array(
                'Application\Controller\Index' => 'Application\Controller\IndexController'
            ),
        ),
        '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__ . '/../view/layout/layout.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' => array(
                __DIR__ . '/../view',
            ),
        ),
    );
    voici aussi un imprime ecran de la structure.



    Merci d'avance pour votre aide.
    Images attachées Images attachées   

  2. #2
    Membre émérite
    Avatar de amoiraud
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2006
    Messages
    606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2006
    Messages : 606
    Par défaut
    Salut,

    Essaye en ajoutant cette ligne dans ton module.config.php dans la partie controllers :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    'controllers' => array(
            'invokables' => array(
                'Application\Controller\Index' => 'Application\Controller\IndexController',
                'Application\Controller\TestZend' => 'Application\Controller\TestZendController'
            ),
        ),

  3. #3
    Membre éclairé
    Avatar de Jcpan
    Inscrit en
    Août 2008
    Messages
    542
    Détails du profil
    Informations forums :
    Inscription : Août 2008
    Messages : 542
    Par défaut
    Ca ne marche pas, je trouve qu'ils ont compliqué d'avantage le framework, déjà la version 1.xx n'est pas pour les novices la 2 est plus compliquée à prendre en main.

  4. #4
    Membre éclairé Avatar de J0r_x
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2006
    Messages
    804
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2006
    Messages : 804
    Par défaut
    J'ai ceci qui fonctionne avec deux controller :
    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
     
        'controllers' => array(
            'invokables' => array(
                'Authentification\Controller\Authentification'  => 'Authentification\Controller\AuthentificationController',
                'Authentification\Controller\Motdepasse'        => 'Authentification\Controller\MotdepasseController'
     
            ),
        ),
        'router' => array(
            'routes' => array(
                'home' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route'    => '/',
                        'defaults' => array(
                            'controller' => 'Authentification\Controller\Authentification',
                            'action'     => 'index',
                        ),
                    ),
                ),
                'authentification' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route'    => '/authentification',
                        'defaults' => array(
                            'controller' => 'Authentification\Controller\Authentification',
                            'action'     => 'index',
                        ),
                    ),
                ),
                'motdepasse' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route'    => '/motdepasse',
                        'defaults' => array(
                            'controller' => 'Authentification\Controller\Motdepasse',
                            'action'     => 'index',
                        ),
                    ),
                ),
            ),
        ),

  5. #5
    Membre Expert
    Avatar de s.n.a.f.u
    Homme Profil pro
    Développeur Web
    Inscrit en
    Août 2006
    Messages
    2 760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Août 2006
    Messages : 2 760
    Par défaut
    Salut,

    Je ne vois aucune route pour cette url : monurl.com/test

    Peut-être devrais-tu essayer monurl.com/application/default/test

Discussions similaires

  1. Comment creer un ocx pour appel dans page html
    Par minette dans le forum VB 6 et antérieur
    Réponses: 26
    Dernier message: 19/07/2006, 12h21
  2. Creer des user par code dans une base de donnees Interbase
    Par dachir dans le forum Bases de données
    Réponses: 2
    Dernier message: 16/07/2006, 14h55
  3. Réponses: 5
    Dernier message: 10/07/2006, 08h23
  4. [VB6] creer et utiliser un Dll dans VB
    Par Mirna dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 31/05/2006, 15h03
  5. creer champ avec valeur constante dans resultat de requete
    Par freejeje dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 20/05/2005, 10h52

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