09/02/2012, 13h29
|
#4
|
|
Membre confirmé
 Mickaël Développeur Web Inscription : janvier 2009 Messages : 408 Détails du profil  Informations personnelles : Nom :  Mickaël Âge : 23 Localisation : France, Haute Savoie (Rhône Alpes) Informations professionnelles :
Activité : Développeur Web Informations forums :
Inscription : janvier 2009 Messages : 408 Points : 234 Points : 234
|
Yo.
Ta config' est un peu différente de la mienne, du coup j'suis un peu paumé. Je te donne le code de mon index.php ainsi que de mon bootstrap principal pour une application modulaire.
index.php
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
error_reporting(E_ALL);
ini_set("display_errors", 1);
ini_set('soap.wsdl_cache_enabled', '0'); // Pour supprimer la mise en cache du fichier WSDL.
// 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('/home/wwwroot/library'),
realpath('/home/wwwroot/library/font'),
realpath(APPLICATION_PATH.'/modules'),
get_include_path(),
)));
define('ADMIN', 'admin'); // Pour savoir si un utilisateur est admin.
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
$autoloader->suppressNotFoundWarnings(true);
// Create application, bootstrap, and run.
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run(); |
Bootstrap.php
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 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| <?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
/**
* Récupère les données du application.ini.
* Zend_Registry l'objet contenant les données dans le application.ini.
*/
protected function _initConfiguration(){
$config = new Zend_Config($this->getOptions(), APPLICATION_ENV);
$this->_config = $config;
$this->_registry = Zend_Registry::getInstance();
$this->_registry->set('config', $config);
return $config;
}
/**
* Permet de déclarer les Namespaces utiles à l'application.
* @return void
*/
protected function _initDefaultNamespace() {
$moduleLoaders = array();
// Default.
$default = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default_',
'basePath' => APPLICATION_PATH . '/modules/default',
));
$default->addResourceType('lib', 'library/', 'Lib');
// Admin.
$admin = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => APPLICATION_PATH . '/modules/admin',
));
$admin->addResourceType('lib', 'library/', 'Lib');
// Ajout des namespaces.
$moduleLoaders['Default'] = $default;
$moduleLoaders['Admin'] = $admin;
return $moduleLoaders;
}
/**
* Initialize databases.
* @return Zend_Db::factory
*/
protected function _initDb() {
// On charge notre fichier de configuration.
$config = new Zend_Config($this->getOptions());
// On essaie de faire une connexion a la base de données.
try {
$db = Zend_Db::factory($config->db);
//on test si la connexion se fait
$db->getConnection();
}
catch (Exception $e) {
exit($e->getMessage());
}
// On stoque notre dbAdapter dans le registre.
Zend_Registry::set('db', $db);
return $db;
}
protected function _initAuth() {
$storage = new Zend_Auth_Storage_Session();
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
$sessionNamespace->setExpirationSeconds(3600);
$this->_registry->set('session', $sessionNamespace);
$auth = Zend_Auth::getInstance();
$auth->setStorage($storage);
$acl = new Default_Model_AccesRules($auth);
$this->_registry->set('auth', $auth);
$this->_registry->set('acl', $acl);
$authPlugin = new Common_Plugin_Auth_GenerateurCertifs($auth, $acl);
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin($authPlugin);
return $auth;
}
/**
* Initialise la view.
*/
protected function _initView(){
// Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$view = new Zend_View();
$view->setEncoding('ISO-8859-1');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
Zend_Layout::startMvc(array('layout' => 'layout' ,'layoutPath' => APPLICATION_PATH . "/layouts/scripts/"));
$mvc = Zend_Layout::getMvcInstance();
$this->_registry->set('mvc', $mvc);
return $view;
}
/**
* Initialise les view helpers.
*/
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->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=ISO-8859-1');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Générateur de certificats');
}
} |
J'espère que ça t'aidera...
DarkSeiryu
|
|
00
|