I’m super new to CakePHP so I have a feeling that I’m probably just doing something silly, but I’ve been stuck on a problem:
Following the tutorials, I created a controller called UsersController in cakephp/app/Controller/UsersController.php, and a model in cakephp/app/Model/User.php that corresponds to a users table in my database. (Also created a view) From what I understand, the default route to this should be:
mysite.com/cakephp/app/users
However, when I go to that URL, I get the error
The action users is not defined in controller AppController
If I add this to AppController…:
public function users(){
$this->redirect(array('controller' => 'users', 'action' => 'index'));
}
…it will go to the right controller and everything is dandy, but I know that isn’t the way it’s supposed to work. Any idea what I might be doing wrong here?
For your example, it should just be
www.mysite.com/usersThis will look for an index action in the users controller.The “normal” url is
www.mysite.com/controller/action/variablesYou don’t need to define anything in the AppController (for this example).