I am developing a plugin and I’m trying to find the best way to have a set of default config options for it which are automatically used when the plugin is loaded, but also have the ability to customise them for a specific app.
I am struggling to find any good documentation about this for Cake 2.0+
Most of the solutions seem to involve configuring something in the main app bootstrap or making a config file in the main app, which seems like a bad idea because if you forget to do any of those things or don’t do them correctly, the plugin won’t work and it’s relying on the ‘outside’ app, which doesn’t seem right.
At the same time, it also seems like a bad idea to have the user edit some sort of config file within the plugin, as they are then tampering with the plugin itself.
What is the best way to do this (or what does everyone normally do)?
What you should do is put your configuration settings in the plugins bootstrap file in
Plugins/PluginDirectory/Config/bootstrap.php.Then when loading the plugin the user has the option of whether to use the plugin’s bootstrap file (See the CookBook). This appears to be all or nothing though, but you do have the advantage that your default configuration settings could always be used and so the user wouldn’t have to create any config settings themselves.
I have found a plugin development article on the bakery and found this note:
This to me suggests that you can’t overwrite individual plugin settings from the application’s bootstrap file. The user would have to modify the plugin’s bootstrap file instead.
(The article is quite old and appears to be for an older version of cake so I don’t know if things changed in more recent versions. Like you I am having a hard time finding much information on this subject)