FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...
Storing secrets in source-controlled files is a bad idea, but we still need some way to provide these sensitive credentials or configuration values to our projects. This problem is exacerbated in development environments where we are running multiple servers at once. This package let's us solve this problem for servers started with CommandBox.
This package loads up local files as Java Properties for both CommandBox commands and servers. The usage is nearly identical, but with enough gotchas to warrant breaking them out in to separate sections.
One note about the
.envfile: Do not commit it to source control. Add it to your
Another good tip is to create an
.env.examplefile that is source controlled that contains all the keys required in your
.envfile but none of the values.
When loading up the CLI, this package will look for a
.env file in the directory where CommandBox is being loaded or executed. If found it will take the key / value pairs found in the file and store them as CommandBox environment variables. These values are now available in any CommandBox command either using
systemSettings.getSystemSetting( name, defaultValue ), or by using CommandBox's built-in system variable expansion.:
Any time you run a command, if there is a
.env file in the current working directory where the command was run, those vars will be loaded into the environment context of that command only. This is great for localized variables that only apply to a specific project. Note, this feature only kicks in if you are on CommandBox 4.5 or higher.
When starting up a server, this package will look for a
.env file in the webroot of the server starting. If found, it will take the key / value pairs found in the file and store them as Java properties. These values are now available in your web application using the
java.lang.System object and the
getProperty(name, defaultValue) methods (Note: the keys are case-sensitive).
When starting up the CLI, CommandBox will look for a
It will load the file's key / value pairs as environment variables inside CommandBox.
If you change the contents of this file, you will need to reload your shell for the changes to take effect.
If you want to change the name of the global environment file, you can update your module settings:
config set modules.commandbox-dotenv.globalEnvFile = "~/.commandbox.env"
The file name
.env can be overridden, if desired.
For instance, by running:
config set modules.commandbox-dotenv.filename=env.properties
all your file names will need to be
There is currently no way to provide a per-project override.
There are two levels of logging available. You can log to the console every time an
.env file has been loaded by setting the
printOnLoad setting to
config set modules.commandbox-dotenv.printOnLoad=true
You can get further output that shows you the name and value of every variable that was loaded by setting the
verbose setting to
true as well.
config set modules.commandbox-dotenv.verbose=true
verbose setting will only kick in if
printOnLoad is also true.
Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.
|Version||Created||Last Update||Published By||Stable||Actions|
|1.7.1||Sep 18 2019 12:14 PM||Sep 18 2019 12:14 PM|
|1.7.0||Sep 18 2019 12:13 PM||Sep 18 2019 12:13 PM|
|1.6.0||Nov 19 2018 10:10 PM||Nov 19 2018 10:10 PM|
|1.5.0||Oct 25 2018 03:37 PM||Oct 25 2018 03:37 PM|
|1.3.4||Apr 16 2018 04:41 PM||Apr 16 2018 04:41 PM|
|1.3.3||Apr 16 2018 04:39 PM||Apr 16 2018 04:39 PM|
|1.3.2||Apr 16 2018 03:35 PM||Apr 16 2018 03:35 PM|
|1.3.1||Apr 16 2018 03:33 PM||Apr 16 2018 03:33 PM|
|1.3.0||Apr 13 2018 11:12 AM||Apr 13 2018 11:12 AM|
|1.2.2||Jan 19 2018 12:38 PM||Jan 19 2018 12:38 PM|
|1.2.1||Sep 05 2017 12:58 PM||Sep 05 2017 12:58 PM|
|1.2.0||Sep 03 2017 05:15 PM||Sep 03 2017 05:15 PM|
|1.1.2||Jul 03 2017 10:23 AM||Jul 03 2017 10:23 AM|
|1.1.0||Feb 23 2016 10:59 AM||Jun 10 2016 01:57 AM|