0

Trying to get CakePHP work with subfolders for Controllers, Views, or Models is not really working and from what I've read I need to use "Plugins". Right now I have the following folder structure:

/app/Plugin/Manager/
    /Controller
        CandyController.php
    /Models
    /View
        /Candy
            viewCandy.ctp
    ManagerAppController.php
    ManagerAppModel.php

When I try and set my url to: http://localhost/Manager/Candy/viewCandy/123. I get the error message: "ManagerController does not exist". Why is CakePHP not picking up that it should look in the Manager plugin folder?

2
  • 1
    Interestingly here is the answer. Edit /app/config/routes.php and add the line: CakePlugin::load(array('Manager'));
    – MikeMurko
    Aug 13, 2011 at 20:42
  • Yeah, I also noticed that CakePHP 2.0 doesn't load plugins automatically and allows you selectively load them. You should put this as an answer to your own question and accept it - you may even get the "Self-Learner" badge.
    – deizel.
    Aug 14, 2011 at 12:47

2 Answers 2

6

Now that 2.0 has been released the docs are fleshed out a bit more. This is described in the Plugin section of the cookbook.

They suggest putting this in bootstrap.php instead of routes.php:

CakePlugin::loadAll(); // Loads all plugins at once
CakePlugin::load('ContactManager'); //Loads a single plugin
1
  • Switched answer. Thanks for keeping up to date
    – MikeMurko
    Mar 12, 2013 at 15:00
4

Here is the solution:

Go to /app/Config/routes.php and add the line CakePlugin::load(array('YourPluginName')); after the line CakePlugin::routes();. In my case it was line 40.

Basically CakePHP 2.0 doesn't automatically load plugins. I think that's fine and dandy, but there isn't really any documentation for this.

1
  • 1
    Plugins should be loaded on Config/bootstrap.php file, not Config/routes.php.
    – lrepolho
    Mar 12, 2013 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.