class IndexController extends Zend_Controller_Action {
public function loginAction() {
// login related operations triggered from here
}
}
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload() ; # __autoload() magic function used in ZF
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('/var/applications/controllers');
$section = getenv('PLACES_CONFIG') ? getenv('PLACES_CONFIG') : 'live'; # We parse the live section of our config.ini file
$config = new Zend_Config_Ini('/var/applications/config.ini', $section); # We call our config.ini file
Zend_Registry::set('config', $config); # And save it in config var
Zend_Controller_Action_HelperBroker::addPrefix('Cal_Helper');
$layout = Zend_Layout::startMvc('/var/applications/views/scripts/layouts'); # Two step view pattern implementation starts here , also we can assign layout name as first parameter otherwise it will be [layout].phtml as default
$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray()); #Connecting to database
Zend_Db_Table::setDefaultAdapter($db); #Setting default database adapter
Zend_Registry::set('db', $db); #We populate $db var
try { ## And we dispatch here
$frontController->dispatch();
}
catch (Exception $exp) {
$contentType = 'text/html';
header("Content-Type: $contentType; charset=utf-8");
echo 'Unexpected Error :';
echo '<h2>Hata: ' . $exp->getMessage() . '</h2><br /><pre>';
echo $exp->getTraceAsString();
}
[general]
db.adapter = PDO_MYSQL
db.config.host = "localhost"
db.config.username = "usernamehere"
db.config.password = "passwordhere"
db.config.dbname = "yourdbnamehere"
[live : general]
[dev : general]
[test : general]
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)