bonjour tout le monde ,
je débute avec Zend et je me bloque au niveau d'un petit exemple
pr commencer je vous fournis l'arborescence de mon projet
ainsi que le code du fichier index.php
.htaccess
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 <?php // politique traitement des erreurs error_reporting(E_ALL|E_STRICT); ini_set('display_errors', 'on'); // mise en place des répertoires et chargement des classes ini_set('include_path' , ini_get('include_path'). ':../library'); ini_set('include_path' , ini_get('include_path'). ':../application/models'); set_include_path('.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../application/models' . PATH_SEPARATOR . get_include_path()); include "Zend/Loader.php"; include "Zend/Layout.php"; include "Zend/Config.php"; // Chargement de la configuration Zend_Loader::loadClass("Zend_Config_Ini"); Zend_Loader::loadClass("Zend_Registry"); Zend_Loader::registerAutoload(); $config = new Zend_Config_Ini('../config.ini', 'general'); $registry = Zend_Registry::getInstance(); $registry->set('config', $config); // Mise en place du Factory Zend_Loader::loadClass("Zend_DB"); $db = Zend_Db::factory($config->db); //mise en place du Zend_Db_Table Zend_Loader::loadClass("Zend_Db_Table"); Zend_Db_Table::setDefaultAdapter($db); Zend_Loader::loadClass ('Zend_Controller_Front'); // setup controller $front = Zend_Controller_Front::getInstance(); $front->throwExceptions(true); $front->setControllerDirectory('../Application/Controllers'); Zend_Layout::startMvc(array('layoutPath'=>'../application/layouts')); // executer ! $front->dispatch(); ?>
ainsi que mon controlleur IndexController.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
et ma vue index.phtml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <?php class IndexController extends Zend_controller_Action { function indexAction() { $view = new Zend_View(); $view->setScriptPath('../views/scripts/index'); echo $view->render('index.phtml');}}?>
comme vous voyez c'est un exemple très simple , j'essaye d'afficher "bienvenue dans l'application de gestion des étudiants" au niveau de la page d'accueil en accédant à l'url http://localhost/monapplizend/public mais voici le message d'erreur qui m'apparait :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <html> <head></head> <body> <h1> bienvenue dans l'application de gestion des étudiants </h1> </body> </html>
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'index.phtml' not found in path (..\views\scripts\index\)' in C:\wamp\www\monapplizend\library\Zend\View\Abstract.php:875 Stack trace: #0 C:\wamp\www\monapplizend\library\Zend\View\Abstract.php(783): Zend_View_Abstract->_script('index.phtml') #1 C:\wamp\www\monapplizend\application\controllers\IndexController.php(7): Zend_View_Abstract->render('index.phtml') #2 C:\wamp\www\monapplizend\library\Zend\Controller\Action.php(502): IndexController->indexAction() #3 C:\wamp\www\monapplizend\library\Zend\Controller\Dispatcher\Standard.php(293): Zend_Controller_Action->dispatch('indexAction') #4 C:\wamp\www\monapplizend\library\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #5 C:\wamp\www\monapplizend\public\index.php(38): Zend_Controller_Front->dispatch() #6 {main} thrown in C:\wamp\www\monapplizend\library\Zend\View\Abstract.php on line 875
merci d'avance
Partager