Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

About index/index

Which event in the dispatcher is the one that, when the URL is (you know, searching for default index/index), executes? I've tried beforeExecuteRoute, beforeDispatch and beforeNotFoundAction (because I don't have an index action), but I always get the exception for not finding the action.

I have the following event:

public function beforeException(Event $event, Dispatcher $dispatcher, $exception)
        switch ($exception->getCode()) {
            case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
            case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                        'controller' => 'error',
                        'action'     => 'notfound',
                return false;

edited Nov '14

I tought the same, 'cause it throws an exception. It is a solution, but I think this will be a case that fits better in one of the other events I used. BTW, I don't wanna redirect to an error controller, just investigate about my problem.

The problem is that beforeDispatch (who is the very first event triggered in that context, I think), knows that I'm calling index/index, but it just doesn't do the redirection in the IF I use (if the controller and action names are index, do a redirection to index/anotherAction).


You can change it in the router:


Or use the notFound paths option:


I cannot get it to work. Even with your code, and with what I've found in the Router docs:

    $router = new \Phalcon\Mvc\Router();
    $router->add('/', 'Index::conexion');
        'controller'    => 'index',
        'action'        => 'conexion'


$router->handle(); must not be called manually, just return the $router in a service definition


Aww, a service, why I didn't think that it was a service? Now it makes sense, I forgotted it. Thanks.