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

[SOLVED] Phalcon Routing problem in my project

I have an old API project, I want to migrate it to phalcon, meanwhile, I decided to change API Url.

My old request API like /Service/SignUp?do=android

and the new API like /Member/Register?do=android

my question is how can I make the new API compatible with the old version?

Thanks in advanced.



1.9k
Accepted
answer

Do you want to have your API accessible via both URLs? If so, you just can use two routes for one action - one route for the old URL and another for the new one. Something like this:

// Create the router
$router = new \Phalcon\Mvc\Router();

//Define a route
$router->add(
    "/Service/SignUp",
    array(
        "controller" => "member",
        "action"     => "register",
    )
);

//Another route
$router->add(
    "/Member/Register",
    array(
        "controller" => "member",
        "action"     => "register",
    )
);