change:
toCode:$frontController->setControllerDirectory('../application/controllers');
and let me know if it works..Code:$frontController->addControllerDirectory('../application/controllers', 'default');![]()
Hello,
I am trying to set the zendframework configuration. But I have a problem with the controllers. When I use the following URL: [HTML]http://localhost/[/HTML] or [HTML]http://localhost/index.php/index[/HTML]it works fine. But when I use [HTML]http://localhost/index[/HTML] or [HTML]http://localhost/help[/HTML] , it doesn't.
Configuration:
- Mac OS X 10.4.9
- MAMP
- AllowOverride All
public/.htaccess
[PHP]RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L][/PHP]
IndexController
[PHP]<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
// Set a variable to be retrieved inside our view script
$this->view->title = "Hello World!";
}
public function helpAction()
{
$this->view->title = "Help Page";
}
}
[/PHP]
public/index.php
[PHP]<?php
require('../application/config/bootstrap.php');
?>[/PHP]
application/config/bootstrap.php
[PHP]<?php
/* Report all errors directly to the screen for simple diagnostics in the dev environment */
error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
/*
* Add the Zend Framework library to the include path so that we can access the ZF classes
* Also , Add the models directory, so we can take advantage of autoloading them in controllers.
*/
set_include_path('../library' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . '../application/models');
/* Set up autoload so we don't have to explicitely require each Zend Framework class */
require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();
/*
* Setup the Zend Registry
* This will take information from config.ini and
* store it for use in the application
*/
Zend_Loader::loadClass('Zend_Config_Ini');
$config = new Zend_Config_Ini('../application/config/config.ini', 'general'); // general corresponds to the section inside the ini file, you will see later
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
/* Our database info was stored in config.ini, so we will initialize our connection here
* If you do not want to use a database, of course, omit this section. This also stores the connection in the registry.
*/
$db = Zend_Db::factory($config->db->adapter,
$config->db->config->toArray());
Zend_Db_Table_Abstract::setDefaultAdapter($db);
$registry->set('db',$db);
/* Grab instance of the front controller */
$frontController = Zend_Controller_Front::getInstance();
/* Disable error handler so it doesn't intercept all those errors we enabled above or set
* to true to show errors during development, FALSE ON LIVE SERVER
*/
$frontController->throwExceptions(true);
/* Setup controller directory */
$frontController->setControllerDirectory('../application/controllers');
/* Run the application */
$frontController->dispatch(); [/PHP]
What do I have to change?
Last edited by itsme85; 11-09-2008 at 10:15 PM.
change:
toCode:$frontController->setControllerDirectory('../application/controllers');
and let me know if it works..Code:$frontController->addControllerDirectory('../application/controllers', 'default');![]()
Check if .htaccess is working on your web server. That is apache mod_rewrite need to be enabled on web server.
There is a lesson about installing and configuring the Zend Framework including a screencast, a PDF book, and source code for an example application. The screencast is even done on a mac.
I am having the same issue - was this resolved?