Plugin path - As config or custom folder setup?

Sometimes a plugin need a configurable path like \site\greatness\.

There are at least two different ways to add a plugin path to a plugin.

  1. As site.php custom folder setup: https://getkirby.com/docs/developer-guide/configuration/folders
  2. As config.php config: https://getkirby.com/docs/developer-guide/configuration/options

Which do you prefer?

  • Config in config.php
  • Custom folder setup in site.php
  • Not sure

0 voters

If you want you can also add a comment on your thoughts.

Iโ€™m not sure if I understand your question ?
Is this about adding any kind of config variables to a plugin? Or only about a custom-path-variable-for-a-plugin?

Only paths. I looked at https://github.com/getkirby-plugins/patterns-plugin#options and there directory is added as a config value.

I think I already have made up my mind and will keep everything in the config.php. Itโ€™s not that the votes flooded in this time. :wink:

Best practise maybe is to only use site.php for Kirby core folders, not for plugins.

Indeed.

As I see it, c (as in c::set()) is a DI container which collects all Kirby settings. (As is l for localized strings).

For smaller plugins, you could use a convention that prefixes the setting with the plugin name so they are โ€œnamespacedโ€ (as in your patterns plugin example above).

If you should have a really big plugin with loads of config options, you could roll your own DI container and bundle it with your plugin?

1 Like