# ACF Pro as a Composer dependency (without committing your license key unencrypted)

**URL:** <https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690>\
**Category:** trellis\
**Created:** [May 10, 2016, 7:55pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690 "2016-05-10T19:55:52Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![erit](https://discourse.roots.io/user_avatar/discourse.roots.io/erit/32/2349_2.png) [@erit](https://discourse.roots.io/u/erit)\
**Post date:** [February 11, 2017, 12:10am UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/21 "2017-02-11T00:10:10Z")

</div>

I was loading ACF with the keyed download link in a special composer package, but it sometimes required deleting the plugin to get it to update (which disrupted our nice reliable trellis deploys). acf-pro-installer works great, thanks @philippbaschke

---

<div class="post-metadata">

**Author:** ![philippbaschke](https://discourse.roots.io/user_avatar/discourse.roots.io/philippbaschke/32/3598_2.png) [@philippbaschke](https://discourse.roots.io/u/philippbaschke)\
**Post date:** [February 19, 2017, 4:27pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/22 "2017-02-19T16:27:01Z")

</div>

Glad that you like it. 😊

---

<div class="post-metadata">

**Author:** ![ccarnell](https://discourse.roots.io/user_avatar/discourse.roots.io/ccarnell/32/4115_2.png) [@ccarnell](https://discourse.roots.io/u/ccarnell)\
**Post date:** [March 8, 2017, 12:05am UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/23 "2017-03-08T00:05:08Z")

</div>

Hey guys,

Previously I was able to deploy without any issues but now I am getting the MissingKeyException error. I am able to use ACF Pro without any issues in the dev environment, the error only appears when I deploy to staging or production.

The acf\_pro\_key variable exists in each vault.yml file and successfully gets deployed to each remote environment in the .env file. I have re-provisioned the server but continue to get the error when I try to deploy.

Any help would be great 🙂

---

<div class="post-metadata">

**Author:** ![philippbaschke](https://discourse.roots.io/user_avatar/discourse.roots.io/philippbaschke/32/3598_2.png) [@philippbaschke](https://discourse.roots.io/u/philippbaschke)\
**Post date:** [March 13, 2017, 8:41pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/24 "2017-03-13T20:41:30Z")

</div>

Unfortunately I never used Trellis so I can’t really help in that matter. I suspect that the problem occurs in the [`loadDotEnv` method](https://github.com/PhilippBaschke/acf-pro-installer/blob/master/src/ACFProInstaller/Plugin.php#L243). Maybe the `.env` file is not in the current working directory (`getcwd()`)?

Try to find out if the `.env` file is loaded. If it is loaded you have to [check the environment](https://secure.php.net/manual/de/reserved.variables.environment.php) after it is loaded. [`getKeyFromEnv`](https://github.com/PhilippBaschke/acf-pro-installer/blob/master/src/ACFProInstaller/Plugin.php#L227) should be the right place to do it 🙂

Hope that helps. Please let us know if you find out what the problem is (because you don’t seem to be the first one to have it) 😊

---

<div class="post-metadata">

**Author:** ![partounian](https://discourse.roots.io/user_avatar/discourse.roots.io/partounian/32/4335_2.png) [@partounian](https://discourse.roots.io/u/partounian)\
**Post date:** [August 10, 2017, 9:55pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/25 "2017-08-10T21:55:35Z")

</div>

I started getting this issue out of nowhere also, it does not let me deploy to remote servers. Did you happen to solve this?

EDIT: Fixed by removing ACF, running composer update, pushing to remote, then adding it back in.

---

<div class="post-metadata">

**Author:** ![mZoo](https://discourse.roots.io/user_avatar/discourse.roots.io/mzoo/32/1989_2.png) [@mZoo](https://discourse.roots.io/u/mZoo)\
**Post date:** [March 23, 2018, 9:09pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/26 "2018-03-23T21:09:26Z")

</div>

Wouldn’t that mean that you would have to do this everytime you redeploy the site?

---

<div class="post-metadata">

**Author:** ![strarsis](https://discourse.roots.io/user_avatar/discourse.roots.io/strarsis/32/4543_2.png) [@strarsis](https://discourse.roots.io/u/strarsis)\
**Post date:** [March 23, 2018, 10:10pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/27 "2018-03-23T22:10:16Z")

</div>

I just added the ACF Pro key to the site config in vault yml and I had to do this only once.

---

<div class="post-metadata">

**Author:** ![joshb](https://discourse.roots.io/user_avatar/discourse.roots.io/joshb/32/9277_2.png) [@joshb](https://discourse.roots.io/u/joshb)\
**Post date:** [April 17, 2018, 5:54pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/28 "2018-04-17T17:54:35Z")

</div>

I’m trying to get composer to manage ACF Pro.  
Here’s what I have:

 ![image](https://discourse.roots.io/uploads/default/original/2X/1/1039f9692599001c1aa9c4d309a9064c831672b8.png)

Plus I have my key listed in my encrypted vault files.

When I run `composer update` all appears to complete successfully but I’m not able to spot where ACF Pro was installed and it doesn’t show up in wp-admin plugins.

Perhaps I’m missing something…

---

<div class="post-metadata">

**Author:** ![MWDelaney](https://discourse.roots.io/user_avatar/discourse.roots.io/mwdelaney/32/5755_2.png) [@MWDelaney](https://discourse.roots.io/u/MWDelaney)\
**Post date:** [April 17, 2018, 6:11pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/29 "2018-04-17T18:11:25Z")

</div>

You have `"type": "library"`. That should be `"type": "wordpress-plugin"` or `"type": "wordpress-muplugin"`

---

<div class="post-metadata">

**Author:** ![joshb](https://discourse.roots.io/user_avatar/discourse.roots.io/joshb/32/9277_2.png) [@joshb](https://discourse.roots.io/u/joshb)\
**Post date:** [April 17, 2018, 7:15pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/30 "2018-04-17T19:15:21Z")

</div>

I had tried both types and none of them were working.  
Turns out `composer clear-cache` solved the problem.

---

<div class="post-metadata">

**Author:** ![Simeon](https://discourse.roots.io/user_avatar/discourse.roots.io/simeon/32/6000_2.png) [@Simeon](https://discourse.roots.io/u/Simeon)\
**Post date:** [July 5, 2018, 12:01am UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/31 "2018-07-05T00:01:22Z")

</div>

Anyone had issues with acf-pro-installer on a Trellis box with multiple websites? Far as I can tell I’ve done everything right (like I’ve done on a dozen other sites) but it errors out trying to install.

If I run `composer install` on the server it comes up ‘authentication required’ and asks for a username/password. The key is definitely there in the `.env` file so no idea what’s wrong…

It installs fine on development, just not on production.

Edit: Actually this might just be it…

> <https://twitter.com/wp_acf/status/1014476804705288195>

---

<div class="post-metadata">

**Author:** ![EFW](https://discourse.roots.io/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@EFW](https://discourse.roots.io/u/EFW)\
**Post date:** [July 13, 2018, 5:36pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/32 "2018-07-13T17:36:09Z")

</div>

Hi,

I had originally just added ACF in as a plugin through the dashboard so I’ve set up all my custom fields etc. and have the custom fields in a JSON file stored in resources/acf-json. However I want to have it as a proper dependency in composer so that I don’t have to remember to copy it across when I deploy the site. When I copy all the ACF files across to the plugins folder then my custom fields are all there.

I’ve followed all of the above and have ACF installed in the vendor folder. Is this right? ACF isn’t showing in the list of plugins in the dashboard and nothing works until I manually copy the ACF files across to the plugins folder again.

My composer.json is:

```
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.6.10",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
        },
        "require": {
          "philippbaschke/acf-pro-installer": "^1.0",
          "composer/installers": "^1.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.6",
    "composer/installers": "^1.4",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "4.9.7",
    "oscarotero/env": "^1.1.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "johnbillion/extended-cpts": "^4.2",
    "advanced-custom-fields/advanced-custom-fields-pro": "*",
  },

```

I think I’ve twiddled and fiddled with everything so much that I’m not sure where everything’s being set any more.

Any help much appreciated.

---

<div class="post-metadata">

**Author:** ![MWDelaney](https://discourse.roots.io/user_avatar/discourse.roots.io/mwdelaney/32/5755_2.png) [@MWDelaney](https://discourse.roots.io/u/MWDelaney)\
**Post date:** [July 13, 2018, 8:00pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/33 "2018-07-13T20:00:51Z")

</div>

Did you run `composer update` after this? If so, did it say it was installing? Did it give an error?

---

<div class="post-metadata">

**Author:** ![EFW](https://discourse.roots.io/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@EFW](https://discourse.roots.io/u/EFW)\
**Post date:** [July 13, 2018, 8:12pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/34 "2018-07-13T20:12:45Z")

</div>

Hi,

Yes I did and everything seemed fine.

It’s put all the files in the site/vendor folder and not in the web/app/themes/theme-name/vendor folder. Is that right? I know it will have done this because I edited the composer.json file in the site folder and not the theme folder. Everything seems to indicate the site composer file is the right place.

Sorry, can’t think straight!

---

<div class="post-metadata">

**Author:** ![strarsis](https://discourse.roots.io/user_avatar/discourse.roots.io/strarsis/32/4543_2.png) [@strarsis](https://discourse.roots.io/u/strarsis)\
**Post date:** [July 14, 2018, 3:52pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/35 "2018-07-14T15:52:06Z")

</div>

Are you also using `hirak/prestissimo` (global composer package) by chance?  
There is a still open issue with `hirak/prestissimo` and `PhilippBaschke/acf-pro-installer`:

> <https://github.com/PhilippBaschke/acf-pro-installer/pull/20>

---

<div class="post-metadata">

**Author:** ![EFW](https://discourse.roots.io/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@EFW](https://discourse.roots.io/u/EFW)\
**Post date:** [July 14, 2018, 5:14pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/36 "2018-07-14T17:14:05Z")

</div>

> [@strarsis](#):
>
> hirak/prestissimo

No, I don’t think so. How would I check this to be sure?

---

<div class="post-metadata">

**Author:** ![strarsis](https://discourse.roots.io/user_avatar/discourse.roots.io/strarsis/32/4543_2.png) [@strarsis](https://discourse.roots.io/u/strarsis)\
**Post date:** [July 14, 2018, 7:21pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/38 "2018-07-14T19:21:25Z")

</div>

You can try to uninstall it:

```auto
$ composer global remove hirak/prestissimo

```

It is also possible to re-install it (but then the ACF installer wouldn’t work):

```auto
$ composer global require hirak/prestissimo

```

---

<div class="post-metadata">

**Author:** ![EFW](https://discourse.roots.io/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@EFW](https://discourse.roots.io/u/EFW)\
**Post date:** [July 14, 2018, 10:22pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/39 "2018-07-14T22:22:06Z")

</div>

I tried to uninstall it but I don’t think it was installed. I get a runtime exception:  
`[RuntimeException]`  
`Could not read ./composer.json`

```
  file_get_contents(./composer.json): failed to open stream: No such file or   
  directory
```

---

<div class="post-metadata">

**Author:** ![Simeon](https://discourse.roots.io/user_avatar/discourse.roots.io/simeon/32/6000_2.png) [@Simeon](https://discourse.roots.io/u/Simeon)\
**Post date:** [July 14, 2018, 10:34pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/40 "2018-07-14T22:34:26Z")

</div>

BTW I _highly_ recommend adding fields by PHP includes in your theme. Much more reliable than JSON files. I’ve had instances where fields on development have been overwritten on deploy by outdated JSON files.

As an added benefit the fields can’t be edited in the Dashboard either.

> **[ACF | Register fields via PHP](https://www.advancedcustomfields.com/resources/register-fields-via-php/)**
>
> This article will discuss how to register fields and field groups via the functions.php file. There are many benefits to using PHP to register fields, the main of which is customization and distribution. The ability to define fields within the...

---

<div class="post-metadata">

**Author:** ![EFW](https://discourse.roots.io/letter_avatar_proxy/v4/letter/e/43a26b/32.png) [@EFW](https://discourse.roots.io/u/EFW)\
**Post date:** [July 14, 2018, 10:39pm UTC](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690/41 "2018-07-14T22:39:07Z")

</div>

Hi Simeon,

I agree. The main problem is that it doesn’t copy the ACF plugin files across at all so the site shows nothing until I copy those files across manually. I’d just love to be able to get it all working properly so that I know that I can always recreate the site no matter what happens and I won’t have to remember various steps in the process.

I’ll look further into use PHP instead of JSON.

Thanks.

[Previous page](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690.md?page=1)

[Next page](https://discourse.roots.io/t/acf-pro-as-a-composer-dependency-without-committing-your-license-key-unencrypted/6690.md?page=3)
