简体   繁体   中英

Zend_Framework config problem

I'am starting to learn Zend Framework , i set up my first project right and created my database and wrote the action indexAction in IndexController but when i try to see
the url http://localhost/zf-tutorial/public/ i get the following error :

Uncaught exception 'Zend_Db_Adapter_Exception' with message 'Configuration array must have a key for 'username' for login credentials' in /opt/lampp/htdocs/zf-tutorial/library/Zend/Db/Adapter/Abstract.php:292 Stack trace: #0 /opt/lampp/htdocs/zf-tutorial/library/Zend/Db/Adapter/Abstract.php(183): Zend_Db_Adapter_Abstract->_checkRequiredOptions(Array) #1 /opt/lampp/htdocs/zf-tutorial/library/Zend/Db.php(265): Zend_Db_Adapter_Abstract->__construct(Array) #2 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Resource/Db.php(142): Zend_Db::factory('PDO_MYSQL', Array) #3 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Resource/Db.php(154): Zend_Application_Resource_Db->getDbAdapter() #4 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Bootstrap/BootstrapAbstract.php(680): Zend_Application_Resource_Db->init() #5 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Bootstrap/BootstrapAbstract.php(623): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('db') #6 /opt/lampp/htdocs/zf-tut in /opt/lampp/htdocs/zf- tutorial/library/Zend/Db/Adapter/Abstract.php on line 292

I tried several solutions (modifying my config in application.ini) but it didnt work here is a snippet of my application.ini file

[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.params.displayExceptions = 0
phpSettings.date.timezone = "Europe/France"
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.user = mona
resources.db.params.password = mona
resources.db.params.dbname = zf-tutorial
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

any ideas .

thanks.

This line

resources.db.params.user = mona

should read

resources.db.params.username = mona

change resources.db.params.user = mona to resources.db.params.username = mona in your application.ini file.

Zend can't find the attribute username for DB connection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM