skip to Main Content
php -v

gives 7.4

which php

gives 7.4

php test.php with the following test file:

<?php
echo phpversion();
?>

gives 7.4

But when I run the install/bootup script for Craft CMS, it’s executing the file Bootup.php with PHP 5.6.

Under what circumstances will presumably a bash script default to an old php version? I suspect this could be an environment variable in Composer. And how do I get it to run using the desired one?

Apologies if I’m asking the xy question.

2

Answers


  1. Chosen as BEST ANSWER

    Ok, so it turns out the php files in composer have the following shebang:

    #!/usr/bin/env php
    

    For some reason I don't fully understand, this has the effect of ignoring ALIAS and looking for the first php in $PATH instead.

    So the solution I opted for was to find the first php in $PATH, rename it php2 and then using ln -s I made a link in that folder called php and pointed it to the correct php version binary, in my case ln -s /opt/plesk/php/7.4/bin/php php

    Composer and Craft are now running with the desired php version.


  2. Check in composer.json file if you have set platform

    "platform": {
            "php": "5.6"
        }
    

    It’s define your target platform you are going to use in project.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search