I am following tutorial from here . And finally when I couldn't do it properly, I just downloaded the code given there.
My application.ini file is
[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 = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.db.adapter = "Pdo_Mysql"
resources.db.params.charset = "utf8"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "mypassword"
resources.db.params.dbname = "zf2tutorial"
[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
I use this to run server
sudo php -S 0.0.0.0:8080 -t public/ public/index.php
And when I go to browser and give URL as http://0.0.0.0:8080/
and I enter username as "admin" and password as "password", then I get
An error occurred
Application error
Exception information:
Message: The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.
Stack trace:
#0 /usr/share/php/Zend/Auth/Adapter/DbTable.php(369): Zend_Auth_Adapter_DbTable->_authenticateQuerySelect(Object(Zend_Db_Select))
#1 /usr/share/php/Zend/Auth.php(117): Zend_Auth_Adapter_DbTable->authenticate()
#2 /var/www/html/zf-auth-tutorial/application/controllers/AuthController.php(33): Zend_Auth->authenticate(Object(Zend_Auth_Adapter_DbTable))
#3 /var/www/html/zf-auth-tutorial/application/controllers/AuthController.php(16): AuthController->_process(Array)
#4 /usr/share/php/Zend/Controller/Action.php(516): AuthController->indexAction()
#5 /usr/share/php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('indexAction')
#6 /usr/share/php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#7 /usr/share/php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#8 /usr/share/php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#9 /var/www/html/zf-auth-tutorial/public/index.php(26): Zend_Application->run()
#10 {main}
Request Parameters:
array (
'controller' => 'auth',
'action' => 'index',
'module' => 'default',
'username' => 'admin',
'password' => 'ad',
'login' => 'Login',
)
My SQL is
CREATE TABLE IF NOT EXISTS users (
id int(11) NOT NULL AUTO_INCREMENT,
username varchar(50) NOT NULL,
password varchar(50) NOT NULL,
salt varchar(50) NOT NULL,
role varchar(50) NOT NULL,
date_created datetime NOT NULL,
PRIMARY KEY (id)
)
And to insert a record
INSERT INTO users (username, password, salt, role, date_created)
VALUES ('admin', SHA1('passwordce8d96d579d389e783f95b3772785783ea1a9854'),
'ce8d96d579d389e783f95b3772785783ea1a9854', 'administrator', NOW());
These queries are as per the tutorials.
Can anyone show me the error? And I'm not sure if resources.db.params.charset = "utf8" is correct in application.ini file.