Problème de configuration (MVC modulaire)
Bonjour à tous.
Voilà après avoir toucher à Zend dans sa version non modulaire je souhaitais lancé l'application que j'ai fait en version modulaire histoire qu'il y est une partie administration dans un autre modules.
Cependant j'ai un gros problème... Je n'arrive pas à acceder à une autre page que l'index/index de mon module default. et encore lorsque je vais a l'url /default/index/index j'ai le droit à une jolie erreur 500.
Pour information l'url rewriting est bien activé.
Voici la structure de mon application
Code:
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
|
Application
- configs
- application.ini
- modules
- default
- controllers
- indexController.php
- errorController.php
- forms
- layout
- scripts
- layout.phtml
- models
- DbTable
- view
- helper
- scripts
- error
- error.phtml
- index
- index.phtml
- backend (le module 2)
- blog (le module 3)
library
public |
Et voici mes codes sources:
Le fichier index
Code:
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
|
<?php
// 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'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// On lance la session
require_once 'Zend/Session.php';
Zend_Session::start();
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
?> |
le bootstrap
Code:
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
|
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
// Initialisation de la vue
$view = new Zend_View;
$view->doctype('XHTML1_STRICT');
// Ajoutons le au ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
// Retournons le, il sera stocké dans un registre par le bootstrap
// pour utilisation future
return $view;
}
protected function _initSession()
{
// On initialise la session
$session = new Zend_Session_Namespace('watchmydesk', true);
Zend_Registry::set('session', $session);
return $session;
}
protected function _initDefaultNamespace() {
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
$defaultModule = $front->getDefaultModule();
new Zend_Application_Module_Autoloader(array( 'namespace' => '', // pas de namespace
'basePath' => APPLICATION_PATH . '/modules/' . $defaultModule,
));
new Zend_Application_Module_Autoloader(array( 'namespace' => 'backend',
'basePath' => APPLICATION_PATH . '/modules/backend',
));
new Zend_Application_Module_Autoloader(array( 'namespace' => 'wmwall',
'basePath' => APPLICATION_PATH . '/modules/wmwall',
));
}
protected function _initRoutes()
{
$routeur = Zend_Controller_Front::getInstance()->getRouter();
/* exemple de modification de route
$routeur->addRoute('register', new Zend_Controller_Router_Route_Static('register', array(
'module' => 'frontend',
'controller' => 'users',
'action' => 'register'))
);*/
return $routeur;
} |
le boostrap du module backend
Code:
1 2 3 4 5
|
<?php
class Backend_Bootstrap extends Zend_Application_Module_Bootstrap {
}
?> |
Mon fichier application.ini
Code:
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
|
[production]
; initilisation du report d'erreurs pour le mode production
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
; Include path
includePaths.library = APPLICATION_PATH "/../library"
; Bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
; initialisation des modules
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
; Layout
resources.layout.layout = "default"
resources.layout.layoutPath = APPLICATION_PATH "/modules/default/layouts/scripts"
; Views
resources.view.encoding = "UTF-8"
; so auto-loading will find our classes in library/App
autoloadernamespaces[] = "Zend_"
autoloadernamespaces[] = "App_"
appnamespace = "Application"
; initialize database
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "watchmydesk"
resources.db.params.date_format = "YYYY-MM-ddTHH:mm:ss"
resources.db.isDefaultTableAdapter = true
[staging : production]
[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 |
Un de mes controllers
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?php
class Backend_IndexController extends Zend_Controller_Action
{
public function init()
{
parent::init();
$models = $this->_request->getParam('module').'/models';
set_include_path('../application/modules/'.$models . PATH_SEPARATOR . get_include_path());
}
public function indexAction()
{
// action body
}
}
?> |
C'est résolu. C'était du à une erreur appache apparemment...