miguel.nz

How to run composer with a different version of PHP in Siteground

October 31, 2023   |   1 minute read.

So I have Siteground for a while now and sadly the version of PHP they use is still 7.4 on some shared hosting plans. There is an option to change the PHP version for files but this will not have effects on Composer.

I was trying to install some packages and I got these errors:

Problem 1
    - idleberg/vite-manifest is locked to version v0.9.0 and an update of this package was not requested.
    - idleberg/vite-manifest v0.9.0 requires php >=8.0 -> your php version (7.4.33) does not satisfy that requirement.
  Problem 2
    - idleberg/wordpress-vite-assets is locked to version v0.10.0 and an update of this package was not requested.
    - idleberg/wordpress-vite-assets v0.10.0 requires php >=8.0 -> your php version (7.4.33) does not satisfy that requirement.
  Problem 3
    - league/uri is locked to version 6.8.0 and an update of this package was not requested.
    - league/uri 6.8.0 requires php ^8.1 -> your php version (7.4.33) does not satisfy that requirement.

So my solution was:

1. Install composer on my home directory:

wget https://getcomposer.org/download/2.4.3/composer.phar

2. Go on my folder and use this version of composer and a custom version of php, in my case I needed to use PHP 8.1:

/usr/local/php81/bin/php-cli ~/composer.phar install

Liz Taylor! Now all my dependencies have been successfully installed 🎉