Edit NextCloud App on The Run

Hi,

assume I have a NextCloud app that sends HTTP requests to a certain URL, what I’m doing now is that, I specified the URL within the PHP code itself, whenever I need to change the URL I change it on the code, change the app version, upload the app to the server, update the server then the requests are sent to the new URL. I didn’t do any UI to my app,

I was thinking if I have some way to change the URL without all these steps, for example some text field in the NextCloud browser UI, then the app reads the URL from there, how to do that? and is there an example app that can be a good guide for this functionality?

If you just change a string in your code, you won’t need to change the version of the app. Maybe wait for the cache.

If I had to change a single URL from time to time, I would set it in the config.php and retrieve the value using IConfig->getSystemValue():

This is how to call the IConfig class: https://github.com/nextcloud/fulltextsearch/blob/master/lib/Service/ConfigService.php#L68

Then:

$my_url = $this->config->getSystemValue(‘my_url’, ‘’);

is this syntax correct to add inside the config.php?

'server_url' => 'http:************\',

thanks

no backslash, and try not to use some generic name like ‘server_url’, include the name of your app maybe:

'my_app.server_url' => 'https://www.perdu.com/',
1 Like

and by my_app you mean in info.xml the <namespace> tag which could be “TestApp” or the <id> tag which could be testapp ?

It can be whatever you want, the key is a string you will use to get the configured value when using getSystemValue(key)

To do it nicely, try using the name of your app within the key: testapp_server_url or testapp.server_url
something that will not conflict with the core or another app.

1 Like

Thanks, it worked