Option to use an environment variable for the Craft license key #18782
Unanswered
MoritzLost
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We use an environment variable
CRAFT_LICENSE_KEYto set the Craft license. This avoids some problems with local or staging environments, and makes it easier to buy and install a new license on a production server. We use this in ourbootstrap.php:This works and is recognized by Craft. But Craft doesn't know that the license comes from an environment variable. This means that when Craft checks for updates, it will always write the new license key to
config/license.key. We then have to copy and paste that to our.envfile and then delete thelicense.keyfile.What I'd like to see is for Craft to write the license key to our
.envfile automatically, similar to plugin license keys, when those are defined as environment variables. For that to work, Craft would need to know which environment variable is used for the license key. This could either be hardcoded (e.g. toCRAFT_LICENSE_KEY) or made a config setting. In either case, Craft should also check this environment variable automatically before attempting to read theconfig/license.keyfile. Then we could even drop the snippet above from ourbootstrap.php. This new behavior could also be made opt-in, e.g. through a general settinguseEnvironmentVariableForLicenseKey, with allowed values eithertrueorfalse, or maybe the name of the environment variable to use as a string?Beta Was this translation helpful? Give feedback.
All reactions