Bonjour,
Je suis en train de tester ZEND Framework pour voir le temps que je vais gagner à developper un site de gestion de Bdd puis dans un deuxieme temps d'exploitation de ses données et d'automatisation de certaines taches.
Pour le moment les tests ne se passent pas super bien puisque je perd pas mal de temps sur la config !
J'ai suivi le tuto de http://blog.lyrixx.info/zend-framework/
Voici l'arborescence de mon site :
Application.ini
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
| [production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "Frontend"
[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.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "Budget"
resources.db.params.password = "test"
resources.db.params.dbname = "Budget"
resources.db.params.date_format = "YYYY-MM-ddTHH:mm:ss"
resources.db.isDefaultTableAdapter = true |
Bootstrap
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 {
public function run() {
// Cela permet d'avoir le fichier de configuration disponible depuis n'importe ou dans l'application.
Zend_Registry::set('config', new Zend_Config($this->getOptions()));
parent::run();
}
/**
* Initialize Module
*
* @return Zend_Application_Module_Autoloader
*/
protected function _initAutoload() {
$loader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $loader;
}
/**
* Initialize data bases
*
* @return Zend_Db::factory
*/
protected function _initDb() {
//on charge notre fichier de configuration
$config = new Zend_Config($this->getOptions());
//On essaye de faire une connection a la base de donnee.
try {
$db = Zend_Db::factory($config->resources->db);
//on test si la connection se fait
$db->getConnection();
}catch ( Exception $e ) {
exit( $e -> getMessage() );
}
// on stock notre dbAdapter dans le registre
Zend_Registry::set( 'dba', $db );
return $db;
}
/**
* Initialize session
*
* @return Zend_Session_Namespace
*/
protected function _initSession() {
// On initialise la session
$session = new Zend_Session_Namespace('budget', true);
return $session;
}
} |
Ma conf apache :
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
|
NameVirtualHost *:80
<VirtualHost *:80>
ServerName <a href="http://www.budget.fr" target="_blank">www.budget.fr</a>
DocumentRoot /home/buntu/NetBeansProjects/Budget/public
<Directory /home/buntu/NetBeansProjects/Budget/public>
DirectoryIndex index.php index.phtml
# Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost> |
Ma config :
Ubuntu 10.04 - apache 2.2.14 - ZendFramework 1.10.4 - PHP 5.3.2-1
Les logs :
[Sun Jun 13 09:23:03 2010] [error] [client 127.0.0.3] PHP Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in /home/buntu/NetBeansProjects/Budget/library/Zend/Controller/Dispatcher/Standard.php:242\nStack trace:\n#0 /home/buntu/NetBeansProjects/Budget/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))\n#1 /home/buntu/NetBeansProjects/Budget/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()\n#2 /home/buntu/NetBeansProjects/Budget/application/Bootstrap.php(7): Zend_Application_Bootstrap_Bootstrap->run()\n#3 /home/buntu/NetBeansProjects/Budget/library/Zend/Application.php(366): Bootstrap->run()\n#4 /home/buntu/NetBeansProjects/Budget/public/index.php(26): Zend_Application->run()\n#5 {main}\n thrown in /home/buntu/NetBeansProjects/Budget/library/Zend/Controller/Dispatcher/Standard.php on line 242
Si quelqu'un a une idée !
Merci d'avance
Partager