php - Phalcon / MVC / Simple routing not working

Solution:

Since it looks like it's not a named route probably should use named route.

$router->add(
        'connect',
        array(
            'controller'    => 'connexion',
            'action'        => 'connect'
        )
)->setName('connectroute');

And then:

<a id="userMenuEditConnect" onclick="window.location.href = '{{ url(['for': 'connectroute']) }}';">Connect</a>

Answer

Solution:

You need to define the url in dependency injection

$di->set('url',function(){
    $url = new Url();
    $url->setBaseUri('/');
    return $url;
},true);

What you have otherwise is correct. However, I advise against using

{{url('connect')}}

You should use instead

"/connect"

Less dependence on phalcon is better. There're so many bugs. I keep finding them. Very disappointed with the framework.

Source