devpanel-demo / backdrop-cms-quickstart

0 stars 1 forks source link

Use settings.local.php file for database credentials and other tweaks. #2

Closed izmeez closed 2 months ago

izmeez commented 3 months ago

Instead of modifying and using the settings.php file it may be better to leave the default settings.php file unchanged and it can be tracked in git.

Then add a settings.local.php file that is not tracked in git and contains the database credentials and anything else required for the environment. It can also be edited to display errors in the dev environment and to change configuration management from files to database if desired.

Having a settings.local.php file may also be useful when deploying to a production environment on DO or AWS where a different settings.local.php file will be required for the database and whatever else is unique to the production environment and allow preserving any additional changes in the settings.php file resulting from core updates.

This will require changes to the .devpanel/init.sh script.

izmeez commented 3 months ago

@devpanel-kha Thank you for the advice in the slack channel.

I have tested using my fork of the repo with the steps you described.

I used Drupal Forge to create a new instance of Backdrop CMS. I then changed the git remote to use my repo https://github.com/izmeez/backdrop-cms-quickstart.git and doing a git checkout issue-2-create-settings.local.php-file followed by the steps you described, deleting the database and files and then initializing the Backdrop CMS.

I am able to successfully initialize Backdrop with a resulting settings.local.php file with the database credentials, tweaks and private files path. And the default backdrop settings.php file is also downloaded.

Because the settings.local.php file is set to display all errors, some warnings and notices appear. However, Backdrop is fully initialized. I will look for ways to eliminate the Backdrop warnings and notices. I would rather do that than disable display of errors although some people might think users don't want to see them and they can turn it off in the settings.local.php file.

I will add a PR. The first 2 commits in the PR is all that is needed to get started with having a settings.local.php file and you may want to cherry pick those.

The other two commits update the settings.local.php file adding tweaks that include displaying errors and setting the private files path. These can be added now or wait until the errors are resolved.

izmeez commented 3 months ago

I added a commit to the PR that creates the directory files/private by updating the .devpanel/init.sh file. This resolves the errors previously occurring when the private files path was added in the settings.local.php file. This has been tested and now completes the PR for this issue.

izmeez commented 2 months ago

I have also confirmed that the site created with this PR also works on subsequent re-initialization.

izmeez commented 2 months ago

After this PR is merged into the project, future updates of Backdrop core will only require one line to be changed and there will be no need to make changes to the settings.php file, since it will be the default installed by backdrop, and the settings.local.php file will not need to be changed unless there is something particular that is required.

izmeez commented 2 months ago

Just to be clear, when this PR is accepted there is no need to commit settings.php file to git. In fact there will be no Backdrop files in the git repo. It will become a later question of what the user needs to assemble for deployment.