Best place to put config files for extensions?

I’m creating my first extension for Yii - an Active Record behaviour, and it needs some configuration.

Where is the accepted place for extension config files? Under:



or somewhere else?

you can place anywhere since you say its path in the proper place.

But for “better place”, my opinion would be the 1st one (extensions…) :)

Modifying any file in the directory of the extension after its installation makes updates much more difficult.

Don’t assume that every Yii application has a “protected/config” directory. It’s just a convention.

Two possible solutions:

  • Add a property called "configFilePath" to your behavior class (possibly with a default value of "protected/config/my_extension_config"), and let the user decide where to store configuration.

  • Factor out any code that requires configuration data into an application component, which can be configured easily in the main config file and is available anywhere in the application, so your behavior can call its methods when necessary.

Brilliant - thank you for those!

In the end, I looked at the items I was configuring and decided they are best supplied on a per-use basis, so I’m including them as an array when I invoke the class in the behaviours() function.