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 :

Application modulaire [ZF 1.9]


Sujet :

Zend Framework PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 77
    Par défaut Application modulaire
    Bonjour, je réalise une application avec ZF 1.9.4 !
    j'avais commencé à la réaliser sans faire de module. Mais maintenant je me rend compte que j'aurais bien besoin d'un module gestion (admin)
    j'aurais donc besoin d'un coup de main pour pouvoir mettre mon application en appli modulaire sans faire trop de bétises !! Merci

    voici mon arborescence

    WebApp
    -------application
    -------------configs
    -------------controllers
    -------------forms
    -------------layouts
    -------------models
    -------------view
    -------------bootstrap.php
    -------data
    -------library
    --------------Zend
    -------public
    --------------css
    --------------images
    --------------index.php
    --------------.htaccess


    Mon fichier 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
    28
    29
    30
    31
     
    <?php
    // Set the initial include_path. You may need to change this to ensure that 
    // Zend Framework is in the include_path; additionally, for performance 
    // reasons, it's best to move this to your web server configuration or php.ini 
    // for production.
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(dirname(__FILE__) . '/../library'),
        get_include_path(),
    )));
     
    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
     
    // Define application environment
    defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
     
    /** Zend_Application */
    require_once 'Zend/Application.php';  
     
    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV, 
        APPLICATION_PATH . '/configs/application.ini'
    );
     
     
    $application->bootstrap();
    $application->run();
    mon fichier 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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
     
    <?php
     
    /**
     * Application bootstrap
     * 
     * @uses    Zend_Application_Bootstrap_Bootstrap
     * @package QuickStart
     */
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
        /**
         * Bootstrap autoloader for application resources
         * 
         * @return Zend_Application_Module_Autoloader
         */
        protected function _initAutoload()
        {
            $autoloader = new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Default',
                'basePath'  => dirname(__FILE__),
            ));
            return $autoloader;
        }
     
        protected function _initConfig()
        {
            $config = new Zend_Config($this->getOptions());
            Zend_Registry::set('config', $config);
            return $config;
        }
     
        /**
         * Bootstrap the view doctype
         * 
         * @return void
         */
        protected function _initDoctype()
        {
            $this->bootstrap('view');
            $view = $this->getResource('view');
            $view->doctype('XHTML1_STRICT');
        }
    }

    Mon fichier 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
    40
    41
    42
     
    [production]
    ; PHP settings we want to initialize
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
     
    ; Make sure the following is on the include_path
    includePaths.library = APPLICATION_PATH "/../library"
     
    ; Indicate the path and classname of the bootstrap
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
     
    ; Bootstrap resources:
    ; - Front Controller
    ; - Layout
    ; - Database
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
    resources.view[] = 
    resources.db.adapter = "PDO_MYSQL"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = ""
    resources.db.params.dbname = "zend_test"
    resources.db.isDefaultTableAdapter = true
     
    [staging : production]
    ; Were you to have a 'staging' environment, you could customize application
    ; settings here
     
    [testing : production]
    ; For testing, we want to display errors and use a different database
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.db.params.dbname = "zend_test"
     
    [development : production]
    ; For development, we want to display errors and use a different database
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.db.params.dbname = "zend_test"

  2. #2
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 506
    Par défaut
    Bonjour, ton fichier application .ini est incomplet, regarde le tuto ici, surtout la partie modulaire

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 77
    Par défaut
    Salut MaitrePylos, Merci de ta réponse !
    j'ai essayé de suivre le tuto pour la partie modulaire. sans succès

    Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'layout.phtml' not found in path (C:\wamp\www\proxyweb\application\layouts\scripts\;C:\wamp\www\proxyweb\application\layouts\scripts\;C:\wamp\www\proxyweb\application\modules\default\views\scripts\)' in C:\wamp\www\proxyweb\library\Zend\View\Abstract.php:926 Stack trace: #0 C:\wamp\www\proxyweb\library\Zend\View\Abstract.php(829): Zend_View_Abstract->_script('layout.phtml') #1 C:\wamp\www\proxyweb\library\Zend\Layout.php(793): Zend_View_Abstract->render('layout.phtml') #2 C:\wamp\www\proxyweb\library\Zend\Layout\Controller\Plugin\Layout.php(142): Zend_Layout->render() #3 C:\wamp\www\proxyweb\library\Zend\Controller\Plugin\Broker.php(331): Zend_Layout_Controller_Plugin_Layout->postDispatch(Object(Zend_Controller_Request_Http)) #4 C:\wamp\www\proxyweb\library\Zend\Controller\Front.php(957): Zend_Controller_Plugin_Broker->postDispatch(Object(Zend_Controller_Request_Http)) #5 C:\wamp\www\proxyweb\library\Zend\Application\Bootstrap\Bootstrap.php(77): Ze in C:\wamp\www\proxyweb\library\Zend\View\Abstract.php on line 926

    Structure

    WebApp
    -------application
    -------------configs
    -------------modules
    -----------------admin
    ---------------------controllers
    ---------------------forms
    ---------------------layouts
    ---------------------models
    ---------------------view
    ---------------------bootstrap.php
    -----------------default
    ---------------------controllers
    ---------------------forms
    ---------------------layouts
    ---------------------models
    ---------------------view
    ---------------------bootstrap.php
    -------------bootstrap.php
    -------data
    -------library
    --------------Zend
    -------public
    --------------css
    --------------images
    --------------index.php
    --------------.htaccess


    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
    40
    41
    42
    43
    44
    45
    46
     
    [production]
    ; PHP settings we want to initialize
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
     
    ; Make sure the following is on the include_path
    includePaths.library = APPLICATION_PATH "/../library"
     
    ; Indicate the path and classname of the bootstrap
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
     
    resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
    resources.modules[] = ""
     
     
    ; Bootstrap resources:
    ; - Front Controller
    ; - Layout
    ; - Database
    resources.layout.layout = "layout"
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
    resources.view[] = 
    resources.db.adapter = "PDO_MYSQL"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = ""
    resources.db.params.dbname = "zend_test"
    resources.db.isDefaultTableAdapter = true
     
    [staging : production]
    ; Were you to have a 'staging' environment, you could customize application
    ; settings here
     
    [testing : production]
    ; For testing, we want to display errors and use a different database
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.db.params.dbname = "zend_test"
     
    [development : production]
    ; For development, we want to display errors and use a different database
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.db.params.dbname = "zend_test"
    Bootstrap.php (principal)

    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
     
    <?php
     
    /**
     * Application bootstrap
     * 
     * @uses    Zend_Application_Bootstrap_Bootstrap
     * @package QuickStart
     */
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
        /**
         * Bootstrap autoloader for application resources
         * 
         * @return Zend_Application_Module_Autoloader
         */
     
    	 protected function _initDefaultNamespace()
    	 {
    		$this->bootstrap('frontcontroller');
    		$fc = $this->getResource('frontcontroller');
    		$defaultModule = $fc->getControllerDirectory($fc->getDefaultModule());
     
    	new Zend_Application_Module_Autoloader(array(
    		'namespace' => '',
    		'basePath' => APPLICATION_PATH . $defaultModule,
    		));
    	}
    /*	 
        protected function _initAutoload()
        {
            $autoloader = new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Default',
                'basePath'  => dirname(__FILE__),
            ));
            return $autoloader;
        }
    */	
        protected function _initConfig()
        {
            $config = new Zend_Config($this->getOptions());
            Zend_Registry::set('config', $config);
            return $config;
        }
     
        /**
         * Bootstrap the view doctype
         * 
         * @return void
         */
        protected function _initDoctype()
        {
            $this->bootstrap('view');
            $view = $this->getResource('view');
            $view->doctype('XHTML1_STRICT');
        }
    }
    bootstrap (module default)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <?php
    class Default_Bootstrap extends Zend_Application_Module_Bootstrap
    {
     
    }

    bootstrap (module admin)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <?php
    class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
    {
     
    }

  4. #4
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 506
    Par défaut
    Toujours prendre deux secondes pour lire les message d'erreur(la première ligne suffit souvant).

    Donc nous avons

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'layout.phtml' not found in path
    Il dit qu'il ne trouve pas le layout.phtml dans le path, or je regarde ton config.ini et qu'est ce que je vois
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    resources.layout.layout = "layout"
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
    Si je regarde ton arborescence
    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
     
    WebApp
    -------application
    -------------configs
    -------------modules
    -----------------admin
    ---------------------controllers
    ---------------------forms
    ---------------------layouts
    ---------------------models
    ---------------------view
    ---------------------bootstrap.php
    -----------------default
    ---------------------controllers
    ---------------------forms
    ---------------------layouts
    ---------------------models
    ---------------------view
    ---------------------bootstrap.php
    -------------bootstrap.php
    cela ne correspond pas

    donc je modifierais mon fichier de configuration en quelque chose comme :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    # Layout
    resources.layout.layout = "layout"
    resources.layout.layoutPath = APPLICATION_PATH "/modules/default/layouts/scripts"

    Bon code

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    77
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 77
    Par défaut
    Merci MaitrePylos pour ta réponse !
    en effet j'aurais pu le remarquer moi même !
    donc de ce fait le module admin utilisera aussi le layout du module default si je comprend bien ?

  6. #6
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 506
    Par défaut
    Oui

    Si tu veux que admin ai son propre layout, tu peux le modifier dans le bootstrap de admin

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

Discussions similaires

  1. [information] framework GUI pour application modulaire
    Par trolldom dans le forum Windows Forms
    Réponses: 1
    Dernier message: 01/11/2007, 23h40
  2. Problème de refresh dans une application modulaire
    Par TigrouMeow dans le forum Windows Forms
    Réponses: 8
    Dernier message: 11/10/2007, 15h06
  3. Réponses: 7
    Dernier message: 16/06/2007, 12h03
  4. Build / application modulaire
    Par Oscar Hiboux dans le forum Maven
    Réponses: 1
    Dernier message: 05/12/2006, 17h38
  5. Comment faire une application modulaire
    Par JuJu° dans le forum C++Builder
    Réponses: 3
    Dernier message: 04/08/2006, 11h35

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