Is there a Controller property that will allow me to get just /controller/action from the URL without any additional parameters there might be?
At the moment I am having to join $this->name . '/' . $this->action.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t want to construct the string
/users/login, you want the URL that corresponds to the login action of your users controller (for example). That is not necessarily the same as/users/login, and you should not hardcode it!To get a URL that will lead to a controller action, use reverse routing:
Yes, that’s even longer, but it’s the correct way to do it. If one day you decide you want the login URL to be
/loginor/members/entranceinstead of/users/login, you only need to define an appropriate route inroutes.phpwithout rewriting all your hardcoded links.