2

i use PHP Deployer with bitbucket pipelines my deployment worked fine until composer version 2.0 was released. Now i need to downgrade composer to version 1 but i don't know how to set the version.

I know that i can set the PHP Version like this:

set('bin/php', 'php74 -d allow_url_fopen=On');

Hope someone can help me.

Thank you!

6
  • When asking a question, it's good if you include your actual problem as well (more than just "not working"). What actually happens? Commented Nov 10, 2020 at 10:44
  • Oh sorry, my pipeline actually uses composer 2 and this breaks my installation so i need to use composer 1. Commented Nov 10, 2020 at 10:47
  • 3
    That didn't clarify anything about what actually happens. Exactly what breaks and how? Do you get errors? If yes, then add them to the question. Please read How to create a Minimal, Reproducible Example and How do I ask a good question and edit your question accordingly. Commented Nov 10, 2020 at 10:49
  • 1
    I'm just pushing for trying to solve the issue instead of downgrading. Commented Nov 10, 2020 at 10:57
  • I have the same problem. If I call "dep deploy dev" it fails in the deploy:vendors task because the deployer loads the composer version 2.x. I checked the vendors.php recipe and there is an comment which says one can set the composer version with "composer_version", "version". So I added to my deploy.php file the line set('composer_version', '1.10.17') but it has no impact. Commented Nov 15, 2020 at 12:34

1 Answer 1

3

Simply override the bin/composer definition in your deploy.php file (originally located here: https://github.com/deployphp/deployer/blob/6.x/recipe/common.php#L114-L125)

set('bin/composer', function() {
    if (commandExist('composer')) {
        $composer = locateBinaryPath('composer');
    }

    if (empty($composer)) {
        run("cd {{release_path}} && curl -sS https://getcomposer.org/download/1.10.17/composer.phar -o composer.phar");
        $composer = '{{bin/php}} {{release_path}}/composer.phar';
    }

    return $composer;
});
Sign up to request clarification or add additional context in comments.

1 Comment

Rather than downloading the phar file for a particular tag directly, you can pass --1 to Composer's installation script to get the latest 1.x version, in case they release a security fix or similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.