0

I have PHP v7.4 on Ubuntu server. And I have an alternative PHP in the path /opt/php81/bin/ I need to start command composer update with PHP 8.1 I tried like that /opt/php81/bin/php composer update but I see the error

Could not open input file: composer

I tried that /opt/php81/bin/php composer update --working-dir=/var/www/user/data/www/myweb.site and I see the same error.

igramnet
  • 201
  • 1
  • 2
  • 11
  • The shell will not use PATH to find arguments, only commands themselves. You need to provide the full path for `composer` as well (maybe `$(which composer)`?). – Álvaro González Jan 26 '23 at 12:18
  • 1
    Said that, I don't think `php composer` will work. You'll need to invoke the `.phar` file. – Álvaro González Jan 26 '23 at 12:19
  • For a totally different way to do this, Symfony has a [binary](https://github.com/symfony-cli/symfony-cli) which allows you to drop a file in your project called `.php-version` with a version number, and you can run PHP and composer with that specific version (if installed). You don’t need the Symfony framework installed, we use this with WordPress and regular PHP projects, too. – Chris Haas Jan 26 '23 at 12:26
  • Does this answer your question? [Tell Composer to use Different PHP Version](https://stackoverflow.com/questions/32750250/tell-composer-to-use-different-php-version) – Nico Haase Jan 26 '23 at 16:23

1 Answers1

0

I found that this solution works !

/opt/php81/bin/php /usr/local/bin/composer update --working-dir=/var/www/user/data/www/myweb.site
NanoPish
  • 1,379
  • 1
  • 19
  • 35
igramnet
  • 201
  • 1
  • 2
  • 11