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

Aliases in annotation router

Hello everyone!

Just wondering if the annotations router allows for aliases or something. For example, the login page would be accessible with both /account/login AND /login ?

/**
 * @RoutePrefix("/account")
 */
class AccountController
{
    /**
     * @Get("/login")
     */
    public function loginAction() {}
}

Can it be done within the same controller, or do i need a new controller with a route prefix set to /login which forwards the view?

Thanks!



8.1k

Only /account/login is determined in this case.



98.9k
Accepted
answer

Don't use a RoutePrefix:

/**
 */
class AccountController
{
    /**
     * @Get("/account/login")
     * @Get("/login")
     */
    public function loginAction() {}
}


15.1k

Wow, so simple! Why did I not think about that.

Thanks