简体   繁体   中英

Arrange CakePHP plugins into subfolders

I've noticed some people mentioning a similar request for controllers and sometimes models, but I've been unable to find anything on arranging plugins in subfolders.

I want...

/app
    /Plugin
        /Modules
            /Form
                /Controller
            /Gallery
                /Controller
        /SomeStandardPlugin
            /Controller

..so that I can keep all the CMS functionality specific plugins separate.

I've tried:

CakePlugin::load('Form');
CakePlugin::load('Modules/Form');
CakePlugin::load('../Plugin/Modules/Form');

No matter which of the above I try, when I attempt to make use of the controller in one of the plugins, it says:

Error: FormsController could not be found.

Error: Create the class FormsController below in file: app\\Controller\\FormsController.php

(Which would be fine if I didn't want it in a plugin!)

The CookBook didn't mention anything about it either - is it just not supported or am I missing something?

FYI: I'm using CakePHP v2.2.3

The argument for CakePlugin::load is not a path

The first argument for this function, is the name of a plugin. This is the correct way to load a plugin:

CakePlugin::load('Name');

But it will only work if the plugin exists in a location configured using App::build

As such, to organize plugins into subfolders, it's necessary to declare all paths that contain a plugin:

// append app/Plugin/Modules to the path to look for plugins
App::build(array(
    'Plugin' => array(
        APP . 'Plugin/Modules'
     )
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM