Zend Framework - "Invalid controller specified"

I had a problem setting up my Zend Framework application on a real server. It works fine on the local host.

My live server address where I have the application:

http://www.domainname.com/new/

Everything is fine until I try to access my admin module at the URL http://www.domainname.com/new/admin , after which I get an error below.

Any ideas?

An error occurred Page not found Exception information: Message: Invalid controller specified (index) Stack trace: #0 /data/www/www.domainname.com/public_html/new/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /data/www/www.domainname.com/public_html/new/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /data/www/www.domainname.com/public_html/new/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /data/www/www.domainname.com/public_html/new/index.php(27): Zend_Application->run() #4 {main} Request Parameters: array ( 'module' => 'admin', 'controller' => 'index', 'action' => 'index', ) 

Include paths in index.php are set correctly (library and everything else is loaded), index.php file is here:

 // 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')); set_include_path('library'); // Define upload path if (!defined('UPLOAD_PATH')) define('UPLOAD_PATH', realpath(dirname(__FILE__)) . '/upload/'); /** 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(); 

Bootstrap.php file:

 class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initDoctype(){ $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_STRICT'); } protected function _initTimeZone(){ $date = $this->getOption('date'); date_default_timezone_set($date['timezone']); } protected function _initLayoutHelper(){ $this->bootstrap('frontController'); Zend_Controller_Action_HelperBroker::addHelper( new Jakub_Controller_Action_Helper_LayoutLoader()); } protected function _initFlashMessenger(){ $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); if ($flashMessenger->hasMessages()) { $view = $this->getResource('view'); $view->messages = $flashMessenger->getMessages(); } } protected function _initAuth(){ $this->bootstrap('session'); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $view = $this->getResource('view'); $view->user = $auth->getIdentity(); } return $auth; } } 

File Application.ini:

 [production] webhost = "http://www.domainname.com/new" phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 includePaths.library = APPLICATION_PATH "/../library" date.timezone = "Europe/Bratislava" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" autoloadernamespaces.nette = "Nette_" autoloadernamespaces.jakub = "Jakub_" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.view[] = resources.view.helperPath.App_View_Helper = APPLICATION_PATH "/views/helpers" resources.modules[] = resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/default/" resources.layout.layout = default admin.resources.layout.layoutPath = APPLICATION_PATH "/modules/admin/layouts/scripts/base/" admin.resources.layout.layout = default [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] webhost = "http://domainname" phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 
+7
source share
3 answers

In the administrator module folder, verify that IndexController.php exists in the "controllers" subdirectory.

If so, then open IndexController.php and make sure that the class declaration does declare the class "IndexController" (shared copy + paste)

Edit: The controller name should be Admin_IndexController, not just IndexController

+5
source

try in application.ini:

 resources.frontController.moduleControllerDirectoryName = "controllers" 

I also have this in my application.ini application for my module:

 resources.frontController.params.prefixDefaultModule = "" 

Does each module also have its own bootstrap?

 <?php class Admin_Bootstrap extends Zend_Application_Module_Bootstrap { //put your code here } 
0
source

I used the authorization controller prepared by my colleague and I had the same problem and I found the problem in redirecting the controller.

 if (!$this->_acl->isAllowed(Zend_Registry::get('user_role'), $module . ':' . $controller, $action)) { $request->setModuleName('default')->setControllerName('authentication')->setActionName('login');} 

This basically checks if you are logged in, and if you have access rights to the specified controller, and if not, it redirects you (in this case) to the default / authenticaion / index Unfortunately, the redirection options are not displayed in the message about an error. I realized that I do not have a controller that I redirect to the finished one, so in some cases this may be the same problem.

0
source

All Articles