Bonjours,Je viens de mettre en place un syteme modulaire qui fonctionne bien.
Sauf que pour la peine, quand je veux cherher une classe sa marche pas avec le message d'erreur qui va avec.
Voici mon Bootstrap principale :
Donc dans modules/default/controllers/IndexController.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
32
33
34
35
36
37
38 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { public function run() { // Cela permet d'avoir la configuration disponible de partout dans notre application Zend_Registry::set('config', new Zend_Config($this->getOptions())); parent::run(); } protected function _initDefaultNamespace() { $this->bootstrap('frontcontroller'); $fc = $this->getResource('frontcontroller'); $defaultModule = $fc->getControllerDirectory($fc->getDefaultModule()); new Zend_Application_Module_Autoloader(array( 'namespace' => '', // pas de namespace 'basePath' => APPLICATION_PATH . $defaultModule, )); } protected function _initView() { // Initialize view $view = new Zend_View(); $view->doctype('XHTML1_STRICT'); $view->headTitle('Ma premiere application avec Zend'); $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=ISO-8859-1'); // Add it to the ViewRenderer $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view); // Return it, so that it can be stored by the bootstrap return $view; } }
Et le model Tuto1.php dans modules/default/model/Tuto1.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 <?php class IndexController extends Zend_Controller_Action { public function init() { $this->view->headTitle('Mon application avec Zend_Application (Utilisateur par défaut)'); } public function indexAction() { $this->_response->appendBody('Bievenue'); } public function testAction() { $tuto1 = new Model_Tuto1(); $this->view->tabTuto1 = $tuto1->find(); } }
Donc on voit bien je veux instancier ma classe.
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 <?php class Model_Tuto1 { private $dbTable; private $id; private $fr; private $en; public function __construct( $id = false ) { $this->dbTable = new Model_DbTable_Tuto1(); if($id) { $tmp = $this->dbTable->getTuto1($id); $this->id = $tmp['id_tuto1']; $this->fr = $tmp['fr']; $this->en = $tmp['en']; } } /* * GET & SET */ public function getDbTable() { return $this->dbTable; } public function getId() { return $this->id; } public function getFr() { return $this->fr; } public function getEn() { return $this->en; } public function setId($id) { $this->id = id; } public function setFr($fr) { $this->fr = $fr; } public function setEn($en) { $this->en = $en; } public function add() { return $this->dbTable->ajouter(array('fr' => $this->fr, 'en' => $this->en)); } public function update() { $this->dbTable->maj(array('id' => $this->id, 'fr' => $this->fr, 'en' => $this->en)); } public function delete() { $this->dbTable->supprimer($this->id); } public function find($tab = false) { $results = $this->dbTable->find($tab); foreach($results as $r) { $ret[] = new Model_Tuto1($r['id_tuto1']); } return $ret; } }
Mais lorque ce je vais sur le site sa dit classe introuvable.
Est un probleme de "autoloader" ?
Comment regler mon probleme ?
merci
Partager