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 :

tuto zend framwework non abouti [ZF 1.11]


Sujet :

Zend Framework PHP

  1. #1
    Nouveau membre du Club
    Femme Profil pro
    Webmaster
    Inscrit en
    Février 2012
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Centrafrique

    Informations professionnelles :
    Activité : Webmaster
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Février 2012
    Messages : 44
    Points : 31
    Points
    31
    Par défaut tuto zend framwework non abouti
    Salut a tous voila j'ai realiser le tuto Débuter avec Zend Framework voila j'arrive a afficher le controller et mon views fonctionne affiche bdd Album mais quand il s'agit d'ajouter et modifier des nouveaux albums
    cela ne fonctionne pas pourtant j'ai bien suivi et ajouter tout dans les views:
    voici mon
    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
    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
    <?php
     
    class IndexController extends Zend_Controller_Action
    {
     
        public function init()
        {
            /* Initialize action controller here */
        }
     
        public function indexAction()
        {
            $this->view->title = "Mes Albums";
        $this->view->headTitle($this->view->title, 'PREPEND');
        $albums = new Model_DbTable_Albums();
        $this->view->albums = $albums->fetchAll();
        }
     
        public function addAction()
        {
            $this->view->title = "Ajouter un nouvel album";
        $this->view->headTitle($this->view->title, 'PREPEND');
     
        $form = new Form_Album();
        $form->envoyer->setLabel('Ajouter');
        $this->view->form = $form;
     
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $artiste = $form->getValue('artiste');
                $titre = $form->getValue('titre');
                $albums = new Model_DbTable_Albums();
                $albums->ajouterAlbum($artiste, $titre);
     
                $this->_redirect('/');
            } else {
                $form->populate($formData);
            }
        }
        }
     
        public function editAction()
        {
            $this->view->title = "Modifier l'album";
        $this->view->headTitle($this->view->title, 'PREPEND');
     
        $form = new Form_Album();
        $form->envoyer->setLabel('Sauvegarder');
        $this->view->form = $form;
     
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $id = (int)$form->getValue('id');
                $artiste = $form->getValue('artiste');
                $titre = $form->getValue('titre');
                $albums = new Model_DbTable_Albums();
                $albums->modifierAlbum($id, $artiste, $titre);
     
                $this->_redirect('/');
            } else {
                $form->populate($formData);
            }
        } else {
            $id = $this->_getParam('id', 0);
            if ($id > 0) {
                $albums = new Model_DbTable_Albums();
                $form->populate($albums->obtenirAlbum($id));
            }
        }
        }
     
        public function deleteAction()
        {
            $this->view->title = "Supprimer l'album";
        $this->view->headTitle($this->view->title, 'PREPEND');
     
        if ($this->getRequest()->isPost()) {
            $supprimer = $this->getRequest()->getPost('supprimer');
            if ($supprimer == 'Oui') {
                $id = $this->getRequest()->getPost('id');
                $albums = new Model_DbTable_Albums();
                $albums->supprimerAlbum($id);
            }
     
            $this->_redirect('/');
        } else {
            $id = $this->_getParam('id', 0);
            $albums = new Model_DbTable_Albums();
            $this->view->album = $albums->obtenirAlbum($id);
        }
        }
     
     
    }
    application.ini
    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
    [production]
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
    phpSettings.date.timezone = "Europe/Paris"
    includePaths.library = APPLICATION_PATH "/../library"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    appnamespace = "Application"
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    resources.layout.layoutpath = APPLICATION_PATH "/layouts"
    resources.frontController.params.displayExceptions = 0
     
    [staging : production]
    resources.db.adapter = "MYSQLI"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = ""
    resources.db.params.dbname = "zftutorial"
    resources.db.params.charset = "utf8"
    resources.db.isDefaultTableAdapter = true
     
     
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
     
    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.frontController.params.displayExceptions = 1
     
    ;
    resources.db.adapter = "MYSQLI"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = ""
    resources.db.params.dbname = "zftutorial"
    resources.db.params.charset = "utf8"
    resources.db.isDefaultTableAdapter = true
    ainsi que le Bootstrap:
    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
    <?php
     
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
     
     
    protected function _initAutoload()
    	{
    		$moduleLoader = new Zend_Application_Module_Autoloader(array(
    			'namespace' => '',
    			'basePath' => APPLICATION_PATH));
    		return $moduleLoader;
    	}
     
    protected function _initViewHelpers()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $view->doctype('XHTML1_STRICT');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
        $view->headTitle()->setSeparator(' - ');
        $view->headTitle(' Tutoriel Zend Framework');
    }
    }
    voila si vous voulez plus de renseignement il ya pas de soucis (merci d'avance votre helpers)

  2. #2
    Membre éprouvé
    Avatar de 5h4rk
    Homme Profil pro
    CTO at TabMo
    Inscrit en
    Février 2011
    Messages
    813
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : CTO at TabMo
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2011
    Messages : 813
    Points : 1 297
    Points
    1 297
    Par défaut
    Bonsoir,
    Pour commencer dire "ça ne marche pas" ne nous aide pas du tout, il faut nous expliquer pourquoi tu dis que ça fonctionne pas.

    Je t'invite dans le add à supprimer le populate qui ne sert à rien et mettre $this->view->form à la fin de ton action.
    Et montre nous également le code de ton formulaire.

    Merci

  3. #3
    Membre régulier
    Femme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2012
    Messages
    107
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Santé

    Informations forums :
    Inscription : Septembre 2012
    Messages : 107
    Points : 86
    Points
    86
    Par défaut
    Bonjour. Pour débuger ton appli, commence déjà par mettre en commentaire tes redirect pour obtenir les messages d'erreur.
    Et montre nous tes messages d'erreur car, même si pour toi le problème est clair, pour nous il l'est beaucoup moins, et avec les informations que tu donne, il est difficile d'en identifier la cause.

  4. #4
    Nouveau membre du Club
    Femme Profil pro
    Webmaster
    Inscrit en
    Février 2012
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Centrafrique

    Informations professionnelles :
    Activité : Webmaster
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Février 2012
    Messages : 44
    Points : 31
    Points
    31
    Par défaut excusez mo de repondre tardivemen
    je montre le formulaire a 5h4rk :
    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
    <?php
     
    class Form_Album extends Zend_Form
    {
        public function __construct($options = null)
        {
            parent::__construct($options);
            $this->setName('album');
     
            $id = new Zend_Form_Element_Hidden('id');
     
            $artiste = new Zend_Form_Element_Text('artiste');
            $artiste->setLabel('Artiste')
                    ->setRequired(true)
                    ->addFilter('StripTags')
                    ->addFilter('StringTrim')
                    ->addValidator('NotEmpty');
     
            $titre = new Zend_Form_Element_Text('titre');
            $titre->setLabel('Titre')
                  ->setRequired(true)
                  ->addFilter('StripTags')
                  ->addFilter('StringTrim')
                  ->addValidator('NotEmpty');
     
            $envoyer = new Zend_Form_Element_Submit('envoyer');
            $envoyer->setAttrib('id', 'boutonenvoyer');
     
            $this->addElements(array($id, $artiste, $titre, $envoyer));
        }
    }
    ensuite
    voila ce que m'affiche mes erreurs:
    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
    Exception information:
     
    Message: Action "modifier" does not exist and was not trapped in __call()
    Stack trace:
     
    #0 C:\wamp\www\zf-tutorial\library\Zend\Controller\Action.php(518): Zend_Controller_Action->__call('modifierAction', Array)
    #1 C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('modifierAction')
    #2 C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #3 C:\wamp\www\zf-tutorial\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
    #4 C:\wamp\www\zf-tutorial\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
    #5 C:\wamp\www\zf-tutorial\public\index.php(26): Zend_Application->run()
    #6 {main}  
     
    Request Parameters:
     
    array (
      'controller' => 'index',
      'action' => 'modifier',
      'id' => '1',
      'module' => 'default',
    )
    voila c'est la meme erreur pour ajouter,modifier, et supprimer sauf que l'action change

  5. #5
    Membre habitué
    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2005
    Messages : 161
    Points : 193
    Points
    193
    Par défaut
    Citation Envoyé par ZYTROcypher Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Exception information:
    Message: Action "modifier" does not exist and was not trapped in __call()
    Dans ton controller, tu as ça
    public function editAction()
    Tu cherches l'action "modifier", alors que dans ton controller, l'action s'appelle "edit"...

    J'imagine que tu as la même erreur pour ajouter, supprimer

  6. #6
    Membre régulier
    Femme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2012
    Messages
    107
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Santé

    Informations forums :
    Inscription : Septembre 2012
    Messages : 107
    Points : 86
    Points
    86
    Par défaut
    comme l'a dit madcat, tu appelle une action de ton controlleur qui n'existe pas. C'est ton lien qui n'est pas bon. Soit tu renomme ton action, soit tu modifie ton lien.

  7. #7
    Nouveau membre du Club
    Femme Profil pro
    Webmaster
    Inscrit en
    Février 2012
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Centrafrique

    Informations professionnelles :
    Activité : Webmaster
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Février 2012
    Messages : 44
    Points : 31
    Points
    31
    Par défaut
    Merci 1000 fois a sereine et a toi aussi MadCat34 je débute sur zend alors voila

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. connexion a oracle 8.1.7 non aboutie
    Par freddy000 dans le forum JDBC
    Réponses: 2
    Dernier message: 03/12/2010, 17h31
  2. [ZF 1.10] Tuto' : "Zend Framework : Premiers pas avec Zend_Application"
    Par DarkSeiryu dans le forum MVC
    Réponses: 5
    Dernier message: 07/11/2010, 18h30
  3. Réponses: 2
    Dernier message: 17/11/2007, 16h23
  4. [MySQL] signalement d'une jonction non abouti
    Par lodan dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 24/09/2006, 10h32

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