TransWikia.com

Craft CLI ./craft - can I tell it to use a specific php version when running composer via the CLI?

Craft CMS Asked by jpea on September 4, 2021

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?

One Answer

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.

Answered by jpea on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP