etoa / etoa-gui

EtoA Game GUI
https://etoa.ch
GNU Affero General Public License v3.0
10 stars 7 forks source link

Store database configuration in .env file (PHP dotenv) #321

Open mrcage opened 3 years ago

mrcage commented 3 years ago

Store database configuration in .env file. The .env file shall be excluded from git, but an .env.example file should be added with sample values, e.g.

APP_DEBUG=true
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=etoa_roundx
DB_USERNAME=etoa_roundx
DB_PASSWORD=etoa_roundx

This will make it easier to change these values based on the environment, as there are many ways to pass environment variables to an application. The htdocs/config/db.conf file should be removed in this process, and the install script adapted accordingly.

Use the symfony dotenv library (https://github.com/symfony/dotenv) to load the contents of the file, and access the values using $_ENV superglobal where appropriate (or maybe there is a better way for accessing the variables, open for recommendations).

glaubinix commented 3 years ago

dotenv sounds good. In a first step can then use the env files to configure pimple/silex and once we move over to symfony we can easily integrate this with the framework. Would definitely want to avoid accessing super globals outside of the app bootstrap