views:

46

answers:

2

Hi,

What is the best way to handle unexisting actions in the Zend Framework?

Depending on the controller I want to be able handle the request differently.

BR Niklas

+2  A: 

Add this function to your controller class

public function __call($method, $args){

    if ('Action' == substr($method, -6) && $method != 'indexAction') {
        // If the action method was not found, forward to the index action
        return $this->_forward('index');
    }

    // all other methods throw an exception
    throw new Exception('Invalid method "' . $method . '" called', 500);
}

In this case missing actions will be forwarded to the index action

David Caunt