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!

lvollmer
  • 1,418
  • 2
  • 13
  • 32
  • When asking a question, it's good if you include your actual problem as well (more than just "not working"). What actually happens? – M. Eriksson Nov 10 '20 at 10:44
  • Oh sorry, my pipeline actually uses composer 2 and this breaks my installation so i need to use composer 1. – lvollmer Nov 10 '20 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](https://stackoverflow.com/help/minimal-reproducible-example) and [How do I ask a good question](https://stackoverflow.com/help/how-to-ask) and edit your question accordingly. – M. Eriksson Nov 10 '20 at 10:49
  • 1
    I'm just pushing for trying to solve the issue instead of downgrading. – M. Eriksson Nov 10 '20 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. – Klotz Großer Nov 15 '20 at 12:34
  • @KlotzGroßer Sorry i found no answer for this. I'm still searching, would be awesome if you share the answer when you found it – lvollmer Nov 15 '20 at 13:54

1 Answers1

2

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;
});
Nico
  • 21
  • 2
  • 1
    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. – IMSoP Nov 15 '20 at 20:57