Naming convention for array keys in config.php

In config/config.php I found keys in various styles:

  • alllowercasewhichishardtorad
  • separated_with_underscores
  • separated.with.dots
  • seperated.withDots.andCamelCase

Which one should I use when writing apps? Was this set or at least discussed?

You should put your configs into the appconfig (instead of the config.php file), and there you should use underscores.

1 Like

What exactly do you mean by “appconfig”? As far as I know I can only store app configuration inside the database. I am trying to avoid a UI for my app and therefore want to store configuration in a file.

Is there an alternative to using config/config.php?

Yeah I don’t know your App. Nevertheless app config is supposed to go into the database most of the times. It can also be configured via ./occ config:app:set in that case. Adding an interface which just sets some config values is actually not that hard (you can put it in the advanced settings tab):

Admin module: https://github.com/nextcloud/announcementcenter/blob/master/lib/Settings/Admin.php
Register the module: https://github.com/nextcloud/announcementcenter/blob/master/appinfo/info.xml#L43-L45
Template: https://github.com/nextcloud/announcementcenter/blob/master/templates/admin.php
JS: https://github.com/nextcloud/announcementcenter/blob/master/js/admin.js

You don’t need an endpoint which saves the value, as there is a general endpoint.

If you still don’t want to do that, looking at the config.php . seems to be the currently used method.

Hello,
but this requires an admin PW confirmation, correct?
OCP.AppConfig.setValue('announcementcenter', 'admin_groups', groups);

yes

Post must be at least 10 characters.

I started developing an app for SQL authentication and I want to store the quries in the file for now. I am used to linux and it just seems more convenient to edit a file during initial setup of Nextcloud than have to run occ several times. The only advante I see in the UI is that users would be able to test the queries from inside the app configuration dialog.

@Rello: admin pw configuration would not be a problem to me since the app is core administration