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


#21

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


#22

Glad that you like it. :blush:


#23

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 :slight_smile:


#24

Unfortunately I never used Trellis so I can’t really help in that matter. I suspect that the problem occurs in the loadDotEnv method. 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 after it is loaded. getKeyFromEnv should be the right place to do it :slight_smile:

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) :blush:


#25

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.


#26

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


#27

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


#28

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

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…


#29

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


#30

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


#31

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…


#32

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.


#33

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


#34

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!


#35

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:


#36

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


#38

You can try to uninstall it:

$ composer global remove hirak/prestissimo

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

$ composer global require hirak/prestissimo

#39

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

#40

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.


#41

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.