0

I have installed CakePHP on windows over II7 and i am having problems with the routes. I have created a Model, a Controller and a View for Users.

When i try to access the index view, i do it like this without any problem:

http://myhost/cakephp/users/

But, when I try to add a new user, the view doesn't load properly:

http://myhost/cakephp/users/add/

It shows this error:

Error: AddController could not be found.
Error: Create the class AddController below in file: app\Controller\AddController.php

In order to make it work, i have to do this in app/Config/routes.php:

Router::connect('/users/add', array('controller' => 'users', 'action' => 'add'));

But that wouldn't be necessary if it worked well. Neither the delete or view views load.

What's going on? How can i detect the problem? Thanks.

EDIT

Content of routes.php:

Router::connect('/', array(
    'controller' => 'pages', 'action' => 'display', 'home'
));
Router::connect('/pages/*', array(
    'controller' => 'pages', 'action' => 'display'
));
CakePlugin::routes();
require CAKE . 'Config' . DS . 'routes.php';
bancer
  • 7,475
  • 7
  • 39
  • 58
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • Post all content of `routes.php`. – bancer Sep 19 '12 at 21:50
  • I have updated the post with it. – Alvaro Sep 20 '12 at 08:45
  • Have you done this: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts ? – bancer Sep 20 '12 at 09:11
  • Yeah, i have done it. The problem stills the same plus CSS styles doesn't load. So I added another rule as detailed on here: http://www2.palomar.edu/pages/sphillips/cakephp-with-iis-7-rewrite-rules-in-a-sub-folder/ – Alvaro Sep 20 '12 at 09:14
  • Ok, it seems i have solved it. It was all because of adding a routing prefix using cake bake console... I had to comment this line at core.php //Configure::write('Routing.prefixes', array('users')); – Alvaro Sep 20 '12 at 09:23

1 Answers1

1

Ok, it seems i have solved it. It was all because of adding a routing prefix using cake bake console... I had to comment this line at core.php

 Configure::write('Routing.prefixes', array('users'));
Alvaro
  • 40,778
  • 30
  • 164
  • 336