ACF Pro as a Composer Dependency with Encrypted License Key

Advanced Custom Fields Pro is one of the most useful WordPress plugins around but, maintaining it as a dependency with Composer is a challenge without including your ACF license key unencrypted in your Git repository.

Fortunately, there’s a quick-and-easy way to include your license key in your (hopefully encrypted) Trellis vault.yml file(s):

This guide uses Fränz Friederes‘s private-composer-installer.

Add your ACF key to your vault.yml files

In each of your trellis/group_vars/[environment]/vault.yml files, add the acf_pro_key value:

# Documentation:
vault_mysql_root_password: devpw

# Variables to accompany `group_vars/development/wordpress_sites.yml`
# Note: the site name (``) must match up with the site name in the above file.
        admin_password: admin
            acf_pro_key: YOUR_KEY_HERE
            db_password: example_dbpassword

IMPORTANT: Once this key is added, you must re-create your .env file in each environment to include this new value. For remote environments, performing a deploy will accomplish this.

Add the ACF repository to your composer.json

In the repositories section of your Bedrock project’s composer.json, add the ACF repository:

  "repositories": [
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.7.12",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "{%ACF_PRO_KEY}&t={%version}"
        "require": {
          "ffraenz/private-composer-installer": "^5.0"

Note: The version number above will be the maximum version number Composer will install.

Bonus: To install ACF as an mu-plugin, simply change "type": "wordpress-plugin" to "type": "wordpress-muplugin"

Require Advanced Custom Fields

Still in composer.json, add ACF to the require section:

  "require": {
    "advanced-custom-fields/advanced-custom-fields-pro": "^5.0.0",

Update your Composer dependencies

Run the following from your site directory:

$ composer update

That’s it!

ACF should download and install itself.

Join the discussion on Roots Discourse

Help support our open-source development efforts

Help us grow

Join over 7,800+ subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Follow us on Twitter @rootswp

Ready to checkout?