Daniel15 / simple-nuget-server

A very simple PHP NuGet server
MIT License
116 stars 43 forks source link

Configurable username and password for DBO #8

Closed sunsided closed 9 years ago

sunsided commented 9 years ago

I'm currently working on a Docker image containing Nginx and HHVM in oder to quickly set up this server. It uses some shell scripts to replace the API key in the configuration file and I thought about doing the same with the PDO connection string.

However, from what I can tell, the PDO constructor requires the username and password to the database to be separate parameters, and these are not provided to the constructor in db.php, so there is currently no (sane) way for me make them configurable by the end user through environmental variables.

Can you add support for those in the inc/config.php?

Daniel15 commented 9 years ago

Good catch - I've only used SQLite with this project so I never needed to specify a username or password. Are you planning on using a different database system?

sunsided commented 9 years ago

I thought MariaDB/MySQL would be a good idea. Makes things a bit easier when it comes to manually deleting packages and such things, I guess. :)

Daniel15 commented 9 years ago

I added support for this in 25a6b82fc026fb880ecb684d94db9bd9114d1b98. However, note that you may need to do schema changes to get it working in MySQL. Notably:

Currently the code to create the database tables if they don't exist runs on every request, as that was the easiest way to do it (and allows easy iteration when debugging, you can just delete the SQLite file to get a fresh database on your next request). It might be worth only doing it when an installer script is ran. The installer script could run different DDL statements depending on the database system being used.