Follow up to this guide:
Besides installing ACF PRO natively using composer
it can also be activated programmatically using a PHP constant:
For a Bedrock site this can be accomplished using an environment variable like ACF_PRO_LICENSE
(set in .env
standalone or in vault.yml
in Trellis):
ACF_PRO_LICENSE='<ACF PRO key here>'
ACF_PRO_LICENSE: '<ACF PRO key here>'
The environment variable can be set in the base config (as development
.php) as PHP constant for being used by ACF PRO:
if (env('ACF_PRO_LICENSE')) {
Config::define('ACF_PRO_LICENSE', env('ACF_PRO_LICENSE'));
}
That configuration code of Bedrock sites for setting PHP constants from environment variables is considerably growing with each newly added plugin that supports license keys/configuration from PHP constants like this.
It may be a good idea/time to add a standard library or some other mechanism to Bedrock that has a curated collection of these environment variables and PHP constants (and other variables initialized from environment variables).
I have to duplicate quite some code between existing and newly added Bedrock sites just for setting PHP constants and variables from environment variables.