@bernhard Sounds good! To add to the greater conversation, here's how a .env file approach would work.
A .env file is created for your local development.
A .env file is created on a staging server if one is used.
A .env file is created for the production server.
Each file exists where they will be used and the values match the requirements for the application to run in that location.
Since the .env file for a project is not committed to the repository, a commonly adopted way to document what is needed in it is to create a .env.example file that contains all of the variables used by the application without values.
This is unrelated to @bernhard's reply but I didn't share some ProcessWire specific information in my original post that readers- whether choosing to use .env or not- may want to keep in mind.
.env files are part of a secrets management strategy. Sensitive values should be stored in a separate location, like a password manager.
The config.php file is a sensitive document. ProcessWire provides direction on securing the file on your server, however this doesn't account for workflows like Git or sharing config.php in collaborative situations. Sensitive values committed to a repository (even if it's private) must be considered compromised. It's not just about DB credentials. Here's an example:
/**
* Installer: User Authentication Salt
*
* This value was randomly generated for your system on 2023/02/22.
* This should be kept as private as a password and never stored in the database.
* Must be retained if you migrate your site from one server to another.
* Do not change this value, or user passwords will no longer work.
*
*/
$config->userAuthSalt = "c187bd9fx935ca861f43da592475fe6afa20a63";
Ryan's note says "private as a password", and that's real. Your auth salt must remain the same regardless of where your code is being run so it is a universally sensitive secret whether local, staging, or production. This unique value is part of how ProcessWire hashes passwords in the database. Having a config.php file committed in a repo with this value means that your site/app is now insecure. Removing it from your repo and pushing the change will not make it secure since it's in the commit history.
So now you're faced with the situation of storing that value in addition to your database credentials which change depending on where your site/app is running. That's makes a case for a .env file or a secure solution like @bernhard is developing for his workflow implementation.