1

With the Craft CLI, is there a way to set which php version to use?

The context here is that the server runs PHP 5.4 for another project, but PHP 7.3 is installed at /usr/bin/php73 and is setup in Apache to use that version for this specific site.

With normal composer install I just specify the path to that version like so:

/usr/bin/php73 /usr/bin/composer update

but I want to be able to run updates via the Craft CLI. The CLI tool then uses the composer version on the server. Is there a way to specify what version of php to use when running commands via the CLI?

1
  • 1
    What host/server/linux distro are you running on? This is something you will need to do server side.
    – dmatthams
    Jun 18, 2020 at 19:04

1 Answer 1

1

This is something I completely overlooked, but the Craft CLI is just a PHP wrapper that's executable on the CLI. So this will work:

/usr/bin/php73 craft help or /usr/bin/php73 craft update all

Will run the CLI with the PHP binary of your choice.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.