Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring database from bootstrap.php #15641

Closed
oravecz opened this issue Feb 28, 2020 · 4 comments
Closed

Configuring database from bootstrap.php #15641

oravecz opened this issue Feb 28, 2020 · 4 comments
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.

Comments

@oravecz
Copy link

oravecz commented Feb 28, 2020

I have database configuration stored in an external system. In bootstrap.php I fetch the credentials. How do I pass them, or set a variable, so the matomo database connections use this config data?

@oravecz
Copy link
Author

oravecz commented Feb 28, 2020

I found a plugin that does something like this. It looks like I need to override the settings read from the config.ini.php file, and there is an event that triggers which will allow me to do this.

From the plugin, I see how I can register for the Db.getDatabaseConfig event. I don't think I want to create a plugin in the bootstrap.php file. Is there an easier way to tap into that event registration in the bootstrap.php file?

@tsteur
Copy link
Member

tsteur commented Feb 29, 2020

@oravecz you will want to install this plugin https://plugins.matomo.org/EnvironmentVariables and then configure it like this

putenv("MATOMO_DATABASE_HOST=...");
putenv("MATOMO_DATABASE_PASSWORD=...");

Haven't tested it but likely works.

@tsteur tsteur closed this as completed Feb 29, 2020
@oravecz
Copy link
Author

oravecz commented Feb 29, 2020

So, no way to listen for that event via some code I initialize in bootstrap.php?

Maybe the EventDispatcher.addObserver() function?

I am trying to stay away from plugins because I am deploying this fully configured. Can’t use the admin console to install plugins dynamically. I know I can install the plugin locally by unzipping into a folder, but I’m trying to keep it simple.

—PHP noob here—

@tsteur
Copy link
Member

tsteur commented Feb 29, 2020

@oravecz I can't think of another way unfortunately.

@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

3 participants