Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

[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.4k
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",
    )
);