New to Zend and the problem with routing.
I can get routing using the application.ini file, but I can't get routing to work using bootstrap. I looked through quite a few tutorials, but most of them seem to be related to older versions of the Zend Framework. I am using 1.10.
In my Bootstrap, I have:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initRouter() { $frontController = Zend_Controller_Front::getInstance(); $router = $frontController->getRouter(); $route = new Zend_Controller_Router_Route( 'aaa', array( 'controller' => 'index', 'action' => 'browse' ) ); $router->addRoute('test', $route); } }
And my index.php
// Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->bootstrap() ->run();
If I point my browser to http://www.mysite.com/aaa
I get the following error
An error occurred Page not found Exception information: Message: Invalid controller specified (aaa) Stack trace: #0 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /usr/share/php/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /var/www/mysite.com/directory001/public/index.php(26): Zend_Application->run() #4 {main} Request Parameters: array ( 'controller' => 'aaa', 'action' => 'index', 'module' => 'default', )
It seems so straightforward, but doesn't seem to work.
Can anyone understand what I can do wrong?