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.

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!



7.2k

Only /account/login is determined in this case.



84.5k
Accepted
answer

Don't use a RoutePrefix:

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


9.9k

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

Thanks