phpcakephpcakephp-2.0

CakePHP admin panel add / edit / view missing controllers


I'm working on an adminpanel within CakePHP.

I have UsersController.php in app/plugins/Users/Controllers/

if I go to {site_url}/admin/users/ I get a list of all users. But when I want to add or edit an user with {site_url}/admin/users/add or {site_url}/admin/users/edit/1

I get the following error:

Error: UsersController could not be found.

Error: Create the class UsersController below in file: app/Controller/UsersController.php

Routers:

Router::connect('/admin/:controller/:action/*', array(
    'action' => null, 'prefix' => 'admin', 'admin' => true
)); 

Router::connect('/admin', array('plugin' => 'Users', 'controller' => 'users', 'action' => 'dashboard', 'admin' => true, 'layout' => 'admin'));
    
if ($plugins = App::objects('plugin')) {
    $pluginMatch = implode('|', array_map(array('Inflector', 'underscore'), $plugins));
    Router::connect(
        "/admin/:plugin/:controller/:action/*",
        array('action' => null, 'prefix' => 'admin', 'admin' => true),
        array('plugin' => $pluginMatch)
    );
} 

Solution

  • Why don't you just use the already supplied routes which work (with prefix routing)?

    https://github.com/cakephp/cakephp/blob/master/app/Config/routes.php#L45