Code Monkey home page Code Monkey logo

private-composer-installer's Introduction

private-composer-installer

Packagist version MIT license Build Status Coverage Status Packagist downloads

This is a Composer plugin offering a way to reference private package URLs within composer.json and composer.lock. It outsources sensitive dist URL parts (license keys, tokens) into environment variables or a .env file typically ignored by version control. This is especially useful when you can't use Private Packagist or Basic HTTP Auth because the source of a package is not in your control. This repository is inspired by acf-pro-installer.

Quick overview

  • This plugin is compatible with both Composer 2.x (latest) and 1.x.
  • When installing or updating a package, the dist URL {%VERSION} placeholder gets replaced by the version set in the package. In Composer 1 the dist URL version gets fulfilled before it is added to composer.lock.
  • Before downloading the package, {%VARIABLE} formatted placeholders get replaced by their corresponding environment variables in the dist URL. Env vars will never be stored inside composer.lock.
  • If an environment variable is not available for the given placeholder the plugin trys to read it from the .env file in the working directory or in one of the parent directories. The .env file gets parsed by vlucas/phpdotenv.
  • If an environment variable can't be resolved a MissingEnvException gets thrown.
  • Package dist URLs with no {%VARIABLE} formatted placeholders get ignored by this plugin.

Examples

Arbitrary private packages

Add the desired private package to the repositories field inside composer.json. Find more about Composer repositories in the Composer documentation. Specify the exact version to install, and use {%VARIABLE} placeholders to specify any sensitive tokens in your .env file.

{
  "type": "package",
  "package": {
    "name": "package-name/package-name",
    "version": "REPLACE_WITH_LATEST_PACKAGE_VERSION",
    "dist": {
      "type": "zip",
      "url": "https://example.com/package-name.zip?key={%PACKAGE_KEY}&version={%VERSION}"
    },
    "require": {
      "ffraenz/private-composer-installer": "^5.0"
    }
  }
}

Provide the private package dist URL inside the .env file:

PACKAGE_KEY=pleasedontusethiskey

Let Composer require the private package:

composer require "package-name/package-name:*"

WordPress plugins

WordPress plugins can be installed using the package type wordpress-plugin in conjunction with the composer/installers installer. In this example we are installing the ACF Pro plugin. Add following entry to the repositories field inside composer.json and set the desired ACF Pro version.

{
  "type": "package",
  "package": {
    "name": "advanced-custom-fields/advanced-custom-fields-pro",
    "version": "REPLACE_WITH_LATEST_ACF_VERSION",
    "type": "wordpress-plugin",
    "dist": {
      "type": "zip",
      "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%VERSION}"
    },
    "require": {
      "composer/installers": "^1.4",
      "ffraenz/private-composer-installer": "^5.0"
    }
  }
}

Provide the ACF Pro key inside the .env file. To get this key, login to your ACF account and scroll down to 'Licenses & Downloads'.

PLUGIN_ACF_KEY=pleasedontusethiskey

Let Composer require ACF Pro:

composer require "advanced-custom-fields/advanced-custom-fields-pro:*"

Configuration

The configuration options listed below may be added to the root configuration in composer.json like so:

{
  "name": "...",
  "description": "...",
  "require": {
  },
  "extra": {
    "private-composer-installer": {
      "dotenv-path": ".",
      "dotenv-name": ".env"
    }
  }
}

dotenv-path

Dotenv file directory relative to the root package (where composer.json is located). By default dotenv files are expected to be in the root package folder or in any of the parent folders.

dotenv-name

Dotenv file name. Defaults to .env.

Dependencies

This package heavily depends on vlucas/phpdotenv to load environment variables "automagically". This may cause version conflicts if your project already depends on it. Refer to this table to set the version of private-composer-installer accordingly or consider upgrading.

vlucas/phpdotenv private-composer-installer
^4.1, ^5.2 ^5.0
^4.0 ^4.0
^3.0 ^3.0, ^2.0
^2.2 ^1.0

Development

Install Composer dependencies:

docker-compose run --rm composer composer install

Before pushing changes to the repository run tests and check coding standards using following command:

docker-compose run --rm composer composer test

This is a project by Fränz Friederes and contributors

private-composer-installer's People

Contributors

ffraenz avatar grahamcampbell avatar ihorvorotnov avatar macbookandrew avatar pierrotevrard-idp avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

private-composer-installer's Issues

Can you place the .env file in a directory above `composer.json`?

We have a project where the .env file is placed in a directory above WordPress and composer.json. This is fine when accessing it normally, as you can specify a path. However, it's hard-coded in Private Composer Installer. We got around it for now by creating a second .env file within the WordPress folder, but it's not ideal. It appears to be hard coded at the moment, so I imagine this is actually a feature request.

Support for newer (v3) version of vlucas/phpdotenv

The vlucas/phpdotenv package version 3 was released about a month ago and includes some great improvements. As this package is a must-have not only for ffraenz/private-composer-installer but for all kinds of projects, the chances that ^3.0 is already in the composer.json are quite high.

However, v3 comes with some breaking changes that you can check in Upgrading Guide. I've done some tests and it seems changing new Dotenv(getcwd()) to Dotenv::create(getcwd()) is the only change needed.

PR is coming in a minute.

Install issue with roots.io Bedrook

Anyone else seeing this issue?

$ composer require "advanced-custom-fields/advanced-custom-fields-pro:*"

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for advanced-custom-fields/advanced-custom-fields-pro * -> satisfiable by advanced-custom-fields/advanced-custom-fields-pro[5.8.9].
    - advanced-custom-fields/advanced-custom-fields-pro 5.8.9 requires ffraenz/private-composer-installer ^2.0 -> satisfiable by ffraenz/private-composer-installer[v2.0.0] but these conflict with your requirements or minimum-stability.

composer.json

{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
  "homepage": "https://roots.io/bedrock/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "[email protected]",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "[email protected]",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "bedrock",
    "composer",
    "roots",
    "wordpress",
    "wp",
    "wp-config"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.8.9",
        "type": "wordpress-muplugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%version}"
        },
        "require": {
          "composer/installers": "^1.4",
          "ffraenz/private-composer-installer": "^2.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1.8",
    "vlucas/phpdotenv": "^4.1.0",
    "oscarotero/env": "^1.2.0",
    "roots/wordpress": "5.3.2",
    "roots/wp-config": "1.0.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "roots/soil": "^3.9",
    "ffraenz/private-composer-installer": "^4.0"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.5.4",
    "roave/security-advisories": "dev-master"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": [
        "type:wordpress-muplugin"
      ],
      "web/app/plugins/{$name}/": [
        "type:wordpress-plugin"
      ],
      "web/app/themes/{$name}/": [
        "type:wordpress-theme"
      ]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "test": [
      "phpcs"
    ]
  }
}

Update ACF PRO white screen of death

Thanks @ffraenz for this installer. Works on all my new install site.

Problem arise when I'm trying to upgrade ACP PRO on an existing site moving from philippbaschke/acf-pro-installer to yours. Did a composer update by changing the value of "vlucas/phpdotenv": "^2.0.1", to "vlucas/phpdotenv": "^3.0.0", and got a white screen of death.

"require": { 
   "php": ">=5.6", "composer/installers": "^1.4",
   "vlucas/phpdotenv": "^3.0.0",
   "johnpbloch/wordpress": "4.9.8",
   "oscarotero/env": "^1.1.0", 
   "roots/wp-password-bcrypt": "1.0.0", 
   "advanced-custom-fields/advanced-custom-fields-pro": "*" 
}

Any idea why is it so? Thanks

Fatal Error with `composer install` and PHP 7

This error occurs when running command composer install

Fatal error: Uncaught TypeError: Argument 1 passed to FFraenz\PrivateComposerInstaller\Plugin::getUrlPlaceholders() must be of the type string, null given

Please, cast the value as a string or allow null

Don't add the version hash to the URL if the exact version can already be found in the URL.

If providing an URL with the version already set in the URL (such as via a Satis repository), since the {%version} variable is not available it will add the version hash to the end of the url.

Example composer repository (created via satis)

{
    "packages": {
        "package-name/package-name" : {
            "1.0.0" : {
                "type": "package",
                "name": "package-name/package-name",
                "version": "1.0.0",
                "dist": {
                    "type": "zip",
                    "url": "https://example.com/download?product=package&u={%USER_ID}&key={%SECRET_KEY}&v=1.0.0"
                },
                "require": {
                    "ffraenz/private-composer-installer": "^2.0"
                },
                "uid": 1
            },
            "1.0.1" : {
                "type": "package",
                "name": "package-name/package-name",
                "version": "1.0.1",
                "dist": {
                    "type": "zip",
                    "url": "https://example.com/download?product=package&u={%USER_ID}&key={%SECRET_KEY}&v=1.0.1"
                },
                "require": {
                    "ffraenz/private-composer-installer": "^2.0"
                },
                "uid": 2
            },
            "1.1.0" : {
                "type": "package",
                "name": "package-name/package-name",
                "version": "1.1.0",
                "dist": {
                    "type": "zip",
                    "url": "https://example.com/download?product=package&u={%USER_ID}&key={%SECRET_KEY}&v=1.1.0"
                },
                "require": {
                    "ffraenz/private-composer-installer": "^2.0"
                },
                "uid": 3
            }
        }
    }
}

This causes the line in composer.lock to be similar to this:

"url": "https://example.com/download?product=package&u={%USER_ID}&key={%SECRET_KEY}&v=1.1.0#1.1.0"

After doing a coposer require of a different package, the version hash will be doubled at the end of the line.

"url": "https://example.com/download?product=package&u={%USER_ID}&key={%SECRET_KEY}&v=1.1.0#1.1.0#1.1.0"

WPML installation stopped working?

Hi there,

As of today, we're no longer able to update WPML plugins through the installer?
Locally everything works fine, but on remote servers composer install fails with these errors:

[Composer\\Downloader\\TransportException]
The 'https://wpml.org/?download=8882&user_id={my_user_id}&subscription_key={my_subscription_key}&version=1.6.1' URL could not be accessed: HTTP/2 403

When I try to access the url in the browser, it downloads the zip package without any problems, when I try to cURL it on my remote server I get a 403 forbidden response?

Anyone else seeing the same?
This happens on multiple projects at the moment.

Thanks!

Conflicts with plugin Hirak/prestissimo

When using this plugin in conjunction with hirak/prestissimo, the download of acf-pro fails because the custom RemoteFileSystem is overwritten. In order to get it working, we should ensure that this plugins runs after hirak/prestissimo.
As both are running with a priority set to 0, setting this one to -1 resolves the issue.

  • Mickaël PERRIN

See this patch for similar fix: PhilippBaschke/acf-pro-installer#20

PluginEvents::PRE_FILE_DOWNLOAD => [ 'injectPlaceholders', -1 ],

Not compatible with vlucas/phpdotenv 4.1.0

There is a dependancy issue with vlucas/phpdotenv 4.1.0.

    - Installation request for advanced-custom-fields/advanced-custom-fields-pro 5.8.7 -> satisfiable by advanced-custom-fields/advanced-custom-fields-pro[5.8.7].
    - Conclusion: remove vlucas/phpdotenv v4.1.0
    - Conclusion: don't install vlucas/phpdotenv v4.1.0
    - advanced-custom-fields/advanced-custom-fields-pro 5.8.7 requires ffraenz/private-composer-installer ^3.0 -> satisfiable by ffraenz/private-composer-installer[v3.0.0, v3.0.1].
    - ffraenz/private-composer-installer v3.0.0 requires vlucas/phpdotenv ^3.0 -> satisfiable by vlucas/phpdotenv[3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, 3.5.x-dev, 3.6.x-dev].
    - ffraenz/private-composer-installer v3.0.1 requires vlucas/phpdotenv ^3.0 -> satisfiable by vlucas/phpdotenv[3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, 3.5.x-dev, 3.6.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.0.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.1.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.2.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.3.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.4.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.5.x-dev].
    - Can only install one of: vlucas/phpdotenv[4.1.x-dev, 3.6.x-dev].
    - Installation request for vlucas/phpdotenv ^4.1.0 -> satisfiable by vlucas/phpdotenv[4.1.x-dev, v4.1.0].

relative composer dependancies:

      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.8.7",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%version}"
        },
        "require": {
          "composer/installers": "^1.4",
          "ffraenz/private-composer-installer": "^3.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1.8",
    "vlucas/phpdotenv": "^4.1.0",```

Allowed memory exhausted when installing v5

When I try to install the package "private-composer-installer" v5 I get the following error message:

- Installing ffraenz/private-composer-installer (v5.0.0): Extracting archive
PHP Fatal error:  Allowed memory size of 8589934592 bytes exhausted (tried to allocate 4294967304 bytes) in %PATH_TO_PROJECT%\vendor\ffraenz\private-composer-installer\src\PrivateComposerInstaller\Environment\LoaderFactory.php on line 47

Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 4294967304 bytes) in %PATH_TO_PROJECT%\vendor\ffraenz\private-composer-installer\src\PrivateComposerInstaller\Environment\LoaderFactory.php on line 47

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

I already tried to increase the memory limit up to 8 GB but the error still occurs.

My Environment:
Windows 10 Pro 2004
PHP 7.2.28 is installed via XAMPP

This problems happens with composer 1.10.16 and composer 2.0.3
Installing v4 works without problems.

Fail installing ACF when running `composer update` after updating to Composer 2

After updating composer to v2 I got a bunch of errors when running composer update, but those were resolved when I updated the version of this installer to ^5.0. Today I'm running into a new error after the 5.0.1 update.

    {
     "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.9.1",
        "type": "wordpress-muplugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%VERSION}"
        },
        "require": {
          "ffraenz/private-composer-installer": "^5.0",
          "composer/installers": "^1.4"
        }
      }
    },

and here's the console output

image

How to setup for a CI build tool?

What is the recommended process for a CI tool such as Travis CI. We are use this package through other WP packages, but since our .env is not committed to source, our CI tools are failing to build our project.

Any direction would be appreciate. Thanks!

Issue with WPML and Bedrock

Hello, I was interested in this package to have a better way to manage WPML using Bedrock by Roots in conjunction of this package.
However, instead of installing the plugin inside the web/app/plugins directory, it installs it inside vendor/wpml/wpml-multilingual-cms.

I tried searching inside the Bedrock documentation and forum, I couldn't find a solution.

My composer.json file:

{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
  "homepage": "https://roots.io/bedrock/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "[email protected]",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "[email protected]",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "wpml/wpml-multilingual-cms",
        "version": "4.2.9",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://wpml.org/?download=6088&user_id={%PLUGIN_WPML_USER_ID}&subscription_key={%PLUGIN_WPML_SUBSCRIPTION_KEY}&version={%version}"
        },
        "require": {
          "composer/installers": "^1.7",
          "ffraenz/private-composer-installer": "^2.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1.7",
    "oscarotero/env": "^1.2.0",
    "roots/wordpress": "5.2.3",
    "roots/wp-config": "1.0.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "vlucas/phpdotenv": "^3.4.0",
    "wpackagist-plugin/wordpress-seo": "^12.2",
    "wpml/wpml-multilingual-cms": "*"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.4.2",
    "roave/security-advisories": "dev-master"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "test": [
      "phpcs"
    ]
  }
}

PhpOption\Option not found

I'm running into the following error when trying to set this up for a new project: `

PHP Fatal error:  Uncaught Error: Class 'PhpOption\Option' not found in \docroot\wp-content\vendor\vlucas\phpdotenv\src\Environment\Adapter\PutenvAdapter.php:28
Stack trace:
#0 \docroot\wp-content\vendor\ffraenz\private-composer-installer\src\PrivateComposerInstaller\Env.php(69): Dotenv\Environment\Adapter\PutenvAdapter->get('ACF_PRO_KEY')
#1 \docroot\wp-content\vendor\ffraenz\private-composer-installer\src\PrivateComposerInstaller\Plugin.php(103): FFraenz\PrivateComposerInstaller\Env->get('ACF_PRO_KEY')
#2 [internal function]: FFraenz\PrivateComposerInstaller\Plugin->injectPlaceholders(Object(Composer\Plugin\PreFileDownloadEvent))
#3 composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(176): call_user_func(Array, Object(Composer\Plugin\PreFileDownloadEvent))

Here's the relevant composer.json portion:

{
  "type": "package",
  "package": {
    "name": "advanced-custom-fields/advanced-custom-fields-pro",
    "version": "5.8.7",
    "type": "wordpress-plugin",
    "dist": {
      "type": "zip",
      "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%VERSION}"
    },
    "require": {
      "composer/installers": "^1.4",
      "ffraenz/private-composer-installer": "^3.0"
    }
  }
}

I've also tried "ffraenz/private-composer-installer": "^2.0" which is working in a different project, so I'm not sure why that error's popping up for this build. Thoughts?

Type content/mu-plugin

I added

"repositories": [
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.9.1",
        "type": "wordpress-muplugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%VERSION}"
        },
        "require": {
          "composer/installers": "^1.4",
          "ffraenz/private-composer-installer": "^3.0"
        }
      }
    }
  ],

in my Sage 10 theme and it now installs the Advanced Custom Fields plugin inside the theme web/app/themes/ventus/wp-content/mu-plugins . I would like it to install elsewhere: web/app/mu-plugins How can I achieve that using the composer.json of the theme?

Compatibility with GitHub Actions?

Has anyone successfully used this package with GitHub Actions? It appears to be as if environment variables are not ready correctly, resulting in failed deployments.

I'm attempting to use the php-actions/composer action, but however I set the environment variable I am constantly facing Can't resolve placeholder {%ACF_PRO_KEY}. Environment variable 'ACF_PRO_KEY' is not set. errors.

- name: Install dependencies
  uses: php-actions/composer@v5
  with:
    php_version: '7.4'
  env:
    ACF_PRO_KEY: ${{ secrets.ACF_PRO_KEY }}

Configuring the ACF_PRO_KEY environment variable globally or even hard coding the value instead of using a secret doesn't work. I have an open issue on the php-actions/composer repository but the author has confirming the configuration is correct.

Could this be related to how GitHub Actions exposes environment variables and this package reads them? For at the moment they do not appear to be compatible.

wpml

i found you mention the option to install wpml as well, but i'm not sure what i am doing wrong here (the name attribute is a guessing by me, not sure if it is correct or if it needs to be something else..?, the url and parameters i grabbed from my wpml account):

    {
      "type": "package",
      "package": {
        "name": "wpml/sitepress-multilingual-cms",
        "version": "4.3.11",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://wpml.org/?download={%PLUGIN_WPML_DOWNLOAD}&user_id={%PLUGIN_WPML_USER_ID}&subscription_key={%PLUGIN_WPML_SUBSCRIPTION_KEY}&t=1585915805&version={%VERSION}"
        },
        "require": {
          "ffraenz/private-composer-installer": "^4.0"
        }
      }
    }

and in my .env file i replace the variables via

PLUGIN_WPML_DOWNLOAD=xxx
PLUGIN_WPML_USER_ID=yyy
PLUGIN_WPML_SUBSCRIPTION_KEY=zzz

plus how would you go on and install the other wpml plugins, like string-translation etc..?
can you help?

Fatal error: Uncaught TypeError: Argument 2 passed to FFraenz\PrivateComposerInstaller\Plugin::fulfillVersionPlaceholder()

We use Composer 1.10 and want to install ACF.

Here is an Excerpt of my composer file

    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.9.1",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k=XXX&t=5.9.1"
        },
        "require": {
          "composer/installers": "^1.4",
          "ffraenz/private-composer-installer": "^5.0"
        }
      }
    },
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1.8",
    "vlucas/phpdotenv": "^4.1.8",
    "oscarotero/env": "^2.1",
    "roots/bedrock-autoloader": "^1.0",
    "roots/wordpress": "5.5.1",
    "roots/wp-config": "1.0.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "advanced-custom-fields/advanced-custom-fields-pro": "*",
  }

The Error:

Fatal error: Uncaught TypeError: Argument 2 passed to FFraenz\PrivateComposerInstaller\Plugin::fulfillVersionPlaceholder() must be of the type string or null, int given, called in /Users/ds/Sites/domain.com/vendor/ffraenz/private-composer-installer/src/PrivateComposerInstaller/Plugin.php on line 182 and defined in /Users/ds/Sites/domain.com/vendor/ffraenz/private-composer-installer/src/PrivateComposerInstaller/Plugin.php:239
Stack trace:
#0 /Users/ds/Sites/domain.com/vendor/ffraenz/private-composer-installer/src/PrivateComposerInstaller/Plugin.php(182): FFraenz\PrivateComposerInstaller\Plugin->fulfillVersionPlaceholder('https://downloa...', 20200811)
#1 [internal function]: FFraenz\PrivateComposerInstaller\Plugin->handlePreInstallUpdateEvent(Object(Composer\Installer\PackageEvent))
#2 phar:///usr/local/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Composer\Installer\PackageEvent))
#3 phar:///usr/local/bin/composer.phar/src/Co in /Users/ds/Sites/domain.com/vendor/ffraenz/private-composer-installer/src/PrivateComposerInstaller/Plugin.php on line 239

How to download Divi theme

https://www.elegantthemes.com/api/api_downloads.php?api_update=1&theme=Divi&api_key={%PLUGIN_DIVI_KEY}&username={%PLUGIN_DIVI_USERNAME}&version={%VERSION}

Found in core/components/Updates.php

Class 'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found

For some reason i'm getting this error when deploying my site after I ran composer update.

PHP
Fatal error: Uncaught Error: Class
'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found in
/www/{site_name}/public/releases/129232182/vendor/ffraenz/private-
composer-installer/src/PrivateComposerInstaller/Plugin.php:102

The error happens at this stage in the deployment Installing advanced-custom-fields/advanced-custom-fields-pro (5.9.1). It's been working fine for months now, so I'm not sure what's going on. Everything works on my local also.

Here's my ACF declaration in my composer.json file.

{
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.9.1",
        "type": "wordpress-muplugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t=5.9.1"
        },
        "require": {
          "ffraenz/private-composer-installer": "^5.0",
          "composer/installers": "^1.4"
        }
      }
    },

Has anyone had this issue before?

This site is hosted on Kinsta and is built using trellis/bedrock/sage.

Composer Install Issue

I just switched over to using this instead of @PhilippBaschke's version but I'm running into the same strange issue. I need to run composer install twice for ACF to install inside of the plugins directory as required. Here's an edited sample of my composer.json file:

{
  "repositories": [
      {
          "type": "composer",
          "url": "https://wpackagist.org"
      },
      {
        "type": "package",
        "package": {
          "name": "advanced-custom-fields/advanced-custom-fields-pro",
          "version": "5.7.13",
          "type": "wordpress-plugin",
          "dist": {
            "type": "zip",
            "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%version}"
          },
          "require": {
            "composer/installers": "^1.0",
            "ffraenz/private-composer-installer": "^2.0"
          }
        }
      }
  ],
  "config": {
      "vendor-dir": "vendor",
      "secure-http": false
  },
  "require": {
      "johnpbloch/wordpress": ">=5.0",
      "advanced-custom-fields/advanced-custom-fields-pro": "*"
  },
  "extra": {
      "installer-paths": {
          "build/wp-content/plugins/{$name}/": [
              "type:wordpress-plugin"
          ],
          "build/wp-content/themes/{$name}/": [
              "type:wordpress-theme"
          ]
      },
      "wordpress-install-dir": "build"
  }
}

Am I doing something wrong which is triggering the need to composer install twice?

Composer plugin doesn't load / work :/

Here's the error

# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 8 installs, 0 updates, 0 removals
  - Installing advanced-custom-fields/advanced-custom-fields-pro (5.8.4): Downloading (failed)       
                                                                                                                 
  [Composer\Downloader\TransportException]                                                                       
  The "https://connect.advancedcustomfields.com/index.php?p=pro&a=download&k={%PLUGIN_ACF_KEY}&t={%version}" fi  
  le could not be downloaded (HTTP/1.1 404 Not Found)                                                            
                                                                                                                 

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

composer.json

{
  "name": "xxx",
  "type": "project",
  "repositories": [{
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.8.4",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download&k={%PLUGIN_ACF_KEY}&t={%version}"
        }
      },
      "require": {
        "composer/installers": "^1.4",
        "ffraenz/private-composer-installer": "^2.0"
      }
    }
  ],
  "config": {
    "vendor-dir": "composer/vendor"
  },
  "require": {
    "johnpbloch/wordpress-core-installer": ">=1.0.2",
    "johnpbloch/wordpress": ">=5.2.3",
    "vlucas/phpdotenv": "^3.5",
    "advanced-custom-fields/advanced-custom-fields-pro": "^5.8"
  }
  "require-dev": {
    "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
    "wp-coding-standards/wpcs": "^2.1",
    "squizlabs/php_codesniffer": "^3.4",
    "phpcompatibility/phpcompatibility-wp": "^2.1",
    "composer/installers": "~1.0"
  }
}

Empty ACF package folder in vendor/

I'm trying to install ACF - everything seems to be running fine but the /vendor/advanced-custom-fields folder is empty.

Here is my package.json:

{

    "repositories": [
        
        {
            "type": "package",
            "package": {
              "name": "advanced-custom-fields/advanced-custom-fields-pro",
              "version": "5.9.1",
              "type": "wordpress-plugin",
              "dist": {
                "type": "zip",
                "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%VERSION}"
              },
              "require": {
                "composer/installers": "^1.4",
                "ffraenz/private-composer-installer": "^5.0"
              }
            }
        }
    ],
    "require": {
        "advanced-custom-fields/advanced-custom-fields-pro": "*"
    },
    "extra": {
        "private-composer-installer": {
          "dotenv-path": ".",
          "dotenv-name": ".env"
        }
    }
}

This is what composer update returns:

Loading composer repositories with package information
Updating dependencies
Dependency resolution completed in 0.002 seconds
Analyzed 141 packages to resolve dependencies
Analyzed 179 rules to resolve dependencies
Lock file operations: 9 installs, 0 updates, 0 removals
Installs: symfony/polyfill-php80:v1.20.0, symfony/polyfill-mbstring:v1.20.0, symfony/polyfill-ctype:v1.20.0, phpoption/phpoption:1.7.5, graham-campbell/result-type:v1.0.1, vlucas/phpdotenv:v5.2.0, ffraenz/private-composer-installer:v5.0.1, composer/installers:v1.9.0, advanced-custom-fields/advanced-custom-fields-pro:5.9.1
  - Locking advanced-custom-fields/advanced-custom-fields-pro (5.9.1)
  - Locking composer/installers (v1.9.0)
  - Locking ffraenz/private-composer-installer (v5.0.1)
  - Locking graham-campbell/result-type (v1.0.1)
  - Locking phpoption/phpoption (1.7.5)
  - Locking symfony/polyfill-ctype (v1.20.0)
  - Locking symfony/polyfill-mbstring (v1.20.0)
  - Locking symfony/polyfill-php80 (v1.20.0)
  - Locking vlucas/phpdotenv (v5.2.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
Installs: symfony/polyfill-php80:v1.20.0, symfony/polyfill-mbstring:v1.20.0, symfony/polyfill-ctype:v1.20.0, phpoption/phpoption:1.7.5, graham-campbell/result-type:v1.0.1, vlucas/phpdotenv:v5.2.0, ffraenz/private-composer-installer:v5.0.1, composer/installers:v1.9.0, advanced-custom-fields/advanced-custom-fields-pro:5.9.1
  - Installing symfony/polyfill-php80 (v1.20.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.20.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.20.0): Extracting archive
  - Installing phpoption/phpoption (1.7.5): Extracting archive
  - Installing graham-campbell/result-type (v1.0.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.2.0): Extracting archive
  - Installing ffraenz/private-composer-installer (v5.0.1): Extracting archive
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
  - Installing composer/installers (v1.9.0): Extracting archive
  - Installing advanced-custom-fields/advanced-custom-fields-pro (5.9.1): Extracting archive
Generating autoload files
8 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Any thoughts?

"Could not find package" (Packagist conflict?)

Using Composer 2.0 & Bedrock (and composer-merge-plugin):

# ~/.config/composer/config.json
{
    "config": {},
    "repositories": {
        "composer-merge-plugin": {
            "type": "github",
            "url": "https://github.com/mcaskill/composer-merge-plugin"
        },
        "advanced-custom-fields/advanced-custom-fields-pro": {
            "name": "advanced-custom-fields/advanced-custom-fields-pro",
            "package": {
                "dist": {
                    "type": "zip",
                    "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k=foobar&t={%VERSION}"
                },
                "name": "advanced-custom-fields/advanced-custom-fields-pro",
                "require": {
                    "composer/installers": "^1.8",
                    "ffraenz/private-composer-installer": "^5.0"
                },
                "type": "wordpress-plugin",
                "version": "1.2.3"
            },
            "type": "package"
        },
        "wpackagist": {
            "type": "composer",
            "url": "https://wpackagist.org"
        }
    }
}

$ composer -vvv require "advanced-custom-fields/advanced-custom-fields-pro:5.9.1"

[...]
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
Downloading https://wpackagist.org/packages.json
[200] https://wpackagist.org/packages.json
Writing /home/foo/.cache/composer/repo/https---wpackagist.org/packages.json into cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2019.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2013.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2012.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-old.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2018.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2015.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2011.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2017.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-this-week.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2020-12.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2014.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2020-06.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2020-09.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2016.json from cache
Reading /home/foo/.cache/composer/repo/https---wpackagist.org/p-providers-2020-03.json from cache
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
Downloading https://repo.packagist.org/packages.json
[200] https://repo.packagist.org/packages.json
Writing /home/foo/.cache/composer/repo/https---repo.packagist.org/packages.json into cache
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
Downloading https://repo.packagist.org/p2/advanced-custom-fields/advanced-custom-fields-pro.json
> pre-file-download: FFraenz\PrivateComposerInstaller\Plugin->handlePreDownloadEvent
Downloading https://repo.packagist.org/p2/advanced-custom-fields/advanced-custom-fields-pro~dev.json
[404] https://repo.packagist.org/p2/advanced-custom-fields/advanced-custom-fields-pro.json
[404] https://repo.packagist.org/p2/advanced-custom-fields/advanced-custom-fields-pro~dev.json

                                                                                                        
  [InvalidArgumentException]                                                                            
  Could not find package advanced-custom-fields/advanced-custom-fields-pro in a version matching 5.9.1  
                                                                                                        

Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Command/InitCommand.php:779
 Composer\Command\InitCommand->findBestVersionAndNameForPackage() at phar:///usr/local/bin/composer/src/Composer/Command/InitCommand.php:443
 Composer\Command\InitCommand->determineRequirements() at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:189
 Composer\Command\RequireCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:310
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:122
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:63
 require() at /usr/local/bin/composer:24

Version constraint for Composer 1 does not allow ACF 5.10.x to update

This issue here:
PhilippBaschke/acf-pro-installer#47

also exists for ffraenz/private-composer-installer when using Composer 1. I got the same error message:

[UnexpectedValueException]
The version constraint of advanced-custom-fields/advanced-custom-fields-pro should be exact (with 3 or 4 digits). Invalid version string "5.10.1"

Updating to Composer 2 does not have this issue.

If using Composer 1, this solution works for philippbaschke, but since ffraenz's isn't acf-pro exclusive, the same solution doesn't look like it applies.
PhilippBaschke/acf-pro-installer@13ec41e

Support for Yith plugins

Hi,

I am trying to install some Yith theme plugins and running in to an issue with auth. I can see from logging in to their site that a cookie is required for the auth and so I have tried setting that as per the composer manual but I still keep getting asked for auth details. I have confirmed the cookie works by using Postman to make a test request so I can only assume the custom header isn't getting set?

{
    "type": "package",
    "options":  {
        "http": {
            "header": [
            "Cookie: login_header_here"
            ]
        }
    },
    "package": {
        "name": "yith/yith-woocommerce-ajax-product-filter",
        "version": "4.4.0",
        "type": "wordpress-plugin",
        "dist": {
            "type": "zip",
            "url": "https://yithemes.com/?wc-api=download-api&request=get_file&licence_key=licence_key&product_id=52749"
        },
        "require": {
            "ffraenz/private-composer-installer": "^5.0"
        }
    }
}

I have tried moving that options block in to various places in case I had it in the wrong one but that hasn't made any difference. Any ideas how to get that Cookie to send with the request?

Support placeholder in other part than dist URL

Hi,

Thank you for your work.

Is there a way to use placeholder in other repositories places?
For example:

"repositories": [
    {
      "type": "composer",
      "url": "https://packages.metabox.io/{%PLUGIN_METABOX_SUBSCRIPTION_KEY}"
    },
...]

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.