8 months ago

Dynamic configuration in service provider

Posted 8 months ago by lambooni

How would I best dynamically update the configuration used in a service provider? for example, if I have an API key for user1, API key for user2 running through the same service provider to connect to an external API service?

for example:

   public function register()
        // Grab config
        $config = $this->app->config->get('xero.config');

        $this->app->bind('XeroPrivate', function () use ($config) {
            return new \XeroPHP\Application\PrivateApplication($config);


I effectively need to be able to switch out the values inside xero.config for different users. Ideally I would use the same service provider and just update the config file prior to instantiating the service provider, but guess I could also store credentials in the database if needed.

Please sign in or create an account to participate in this conversation.