Named routes

Hi, i tried to give my routes custom names, but it doesn't work. I am using Vokuro:

$router->add('/about', [
  'controller' => 'about_control',
  'action' => 'index'
 ])->setName("ueber");

So i don't want

www.mydomain.com/about

i want

www.mydomain.com/ueber

Thx for help :-)

Well use this. Good luck

$router->add('/ueber', [
  'controller' => 'about_control',
  'action' => 'index'
 ])->setName("ueber");


34.9k

Hi,

sorry this is not working , don't know why.

What you mean by not working?



34.9k

That i still get

 www.mydomain.com/about

and not

www.mydomain.com/ueber

can you share the code to generete the url or link?

edited Jul '18

How do you generate your url? Maybe you have just url provided like this in view?



34.9k

Hello,

sorry for my late response, i was busy :-)

sure here we go:

$router = new Phalcon\Mvc\Router();

$router->add('/ueber', [
'controller' => 'about_control',
'action' => 'index'
])->setName("ueber");

return $router;

And where you have this code? In $di->set()? And how you access this route like in view?



34.9k
edited Aug '18

In services.php i have this:

$di->set('router', function () {
    return require APP_PATH . '/config/routes.php';
});

An this in routes.php

$router = new Phalcon\Mvc\Router();

$router->add('/ueber', [
'controller' => 'about_control',
'action' => 'index'
])->setName("ueber");

return $router;

I am using Vokuro as Base System