For security reasons, it would be nice to be able to keep my plugin licenses stored in my .env files and out of the project.yaml file in my repo. Currently it's only possible to have the license defined explicitly in the project config file.
This is possible with the CRAFT_LICENSE_KEY PHP constant.
.env:
LICENSE_KEY="#########..."
web/index.php (after loading .env):
define('CRAFT_LICENSE_KEY', getenv('LICENSE_KEY'));
This is possible with the CRAFT_LICENSE_KEY PHP constant.
For the Craft license sure, but I was talking about specific 3rd party plugin licenses.
Sorry, somehow I missed that!
Just added the ability to set plugin license keys to environment variables using the $VARIABLE_NAME syntax, for the next release. If you do, they will be saved to your project.yaml file the same way, so the license key won鈥檛 make it into your repo.
Fantastic, thank you!
Small problem with this is that the name of the variable has a max length because the field is cut to the length of a license key
@jurriaanr Thanks for pointing that out. Just removed the maxlength input attribute for today鈥檚 3.2.6 release.
For those interested in storing the license key in an environment variable: don't forget to add define('CRAFT_LICENSE_KEY', getenv('LICENSE_KEY')); also to the /craft executable.
Most helpful comment
@jurriaanr Thanks for pointing that out. Just removed the
maxlengthinput attribute for today鈥檚 3.2.6 release.