D
D
Dokuro2015-09-08 13:59:11
PHP
Dokuro, 2015-09-08 13:59:11

How to define a route in Phalcon if the routing is dynamic?

Hello everyone again.
There was a question on routing in Phalcon. I need to make a non-standard route:
dd.lo/profile/UserName
By default, the UserName method is called. But it is necessary that UserName be a parameter of the profile method of the UserController.php controller.
The documentation describes:

<?php
// Создание маршрутизатора
$router = new Phalcon\Mvc\Router();

// Определение правила маршрутизации
$router->add(
    "/admin/users/my-profile",
    array(
        "controller" => "user",
        "action"     => "profile"
    )
);

$router->handle();

But how to "implement" it? If my routing is dynamic... What should I do with the router object? Need to send somewhere?
In short, here is index.php:
<?php
try
{
    /*
        My code...
   */

    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

}
catch (Exception $e)
{
     echo 'PhalconException: ', $e->getMessage();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-09-08
Chan @iDokuro

Read more carefully about routing, everything is perfectly described there:
https://docs.phalconphp.com/en/latest/reference/ro...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question