We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to debug dispatcher behaviour?

I've been trying to incorporate Incubator\Phalcon\Error into my project, and suddenly my dispatcher->forward doesn't work anymore.

I've got this in a controller action:

        $params = $this->dispatcher->getParams();
        if (empty($params)) {
            $this->dispatcher->forward(
                array(
                    'controller' => 'front',
                    'action' => 'homepage'
                )
            );
        }

But it seems like it passes through the dispatcher->forward, and continues. I did a die(var_dump($this->dispatcher)); after it, and dispatcher does seem to show it should be going to the right place, but it doesn't do that. Can you please advise how to debug this?



98.9k

Try returning 'false' after doing the forward this will tell Phalcon\Dispatcher that it must stop the current operation.

That worked! Thanks!