Answer the question
In order to leave comments, you need to log in
Where to store and how to load configs and parameters (main-local, params-local) in Yii2?
Hello. Please tell me who solves the following situation:
There is an application on which the development team is continuously working. The application will be independently deployed on multiple servers (dedik or vps). The codebase is the same. Each production server requires application configuration (database connection and other parameters unique for each server) using main-local and params-local.
If we take yii2-app-advanced as an example, it is supposed to use files for configs and parameters main.php and params.php which are in the repository, and to "overlap" the local parameters of the production server, main-local.php and params-local.php are used, which should not be in the repository (contain confidential data) and data for each server are different.
Question: how to upload main-local.php and params-local.php to the server for the production environment, while keeping them up to date for each server? What if someone on the development team reworks something that requires these files to be updated? How not to miss this moment?
upd: I understand that the main-local.php and params-local.php files intended for production can either be uploaded to the server via ftp / sftp or edited directly on the server, but I don’t like this option, because it is easy to make a mistake, and above all it is not fast. For example, I can update the application via git pull, but I can’t fix the configs manually instantly, I will have to stop the application for a while. While the option with a separate git repository for each production server is spinning in my head, then you can update the application like this
cd /var/www/app; git pull; cd /var/www/app-config; git pull
Answer the question
In order to leave comments, you need to log in
It can do as advised https://12factor.net/ru/ and load data into the config for the server prod through environment variables. The config will be something like:
'components' => [
'db' => [
'dsn' => getenv('db_dsn')
...
],
...
]
Add the logic for compiling the final config with reference to the domain on which the system is running
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question