As far as I remember (just not sure), some systems are installing aliases, so you may use php7.1 -v or php5.6 -v in ssh to select the version. php in general may be an alias to the latest version. You may as well use the full path /usr/bin/php7.1.

    php7.1 -v or php5.6 -v just prints version, not selects it. Yes, there are usually many aliases for different purposes. OP uses one of them, and he created alias php himself.

      Staszek of course -v displays the version. Omit -v and add your php-script filename instead

      Staszek I did successfully install composer in flarum directory. However i am still facing the same issue. The installation calls for the system php version and not the composer php version and therefore generates problem. Not sure how to bypass this.

        jahangir I suppose you didn't just run composer <command> hoping it will launch your version of composer, but you did php composer.phar <command>? 😉 If yes, try php7.2 composer.phar <command>. Instead of php7.2 part you may have to use some other alias of php 7.2 command. You can also try to use full path: /opt/php71/bin/php composer.phar <command>, or some other full path, like Broxi suggested.

        5 days later

        Update: after trying a number of solutions, there was a simple trick which helped me avoid php version check and install flarum:

        i used

        --ignore-platform-reqs

        at the end of my command and it simply ignored calling php version check and installed the application successfully. Since my hosting environment already has php 7.1, so the application is running smoothly. Thanks a lot everyone for the help. I will keep updating if i face any further issue.

        update: i tried installing multiple extensions, and i needed same --ignore-platform-reqs at the end of each command to be able to install the extension, otherwise it would give php version error.

        6 days later

        On my server I have multiple versions of PHP from 5 to 7.2, default is 7.0.
        For using Flarum I use this medthod method :

        cga@serveur:~$ which php
        /usr/bin/php
        cga@serveur:~$ php -v
        PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
        Copyright (c) 1997-2017 The PHP Group
        Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
            with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.0.3, Copyright (c) 2002-2017, by ionCube Ltd.
            with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
            

        So I change the $PATH environment variable :

        cga@serveur:~$ export PATH=/opt/plesk/php/7.1/bin:${PATH}
        cga@serveur:~$ which php
        /opt/plesk/php/7.1/bin/php
        cga@serveur:~$ php -v
        PHP 7.1.26 (cli) (built: Jan 11 2019 12:01:51) ( NTS )
        Copyright (c) 1997-2018 The PHP Group
        Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
            with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.1, Copyright (c) 2002-2018, by ionCube Ltd.
            with Zend OPcache v7.1.26, Copyright (c) 1999-2018, by Zend Technologies
        cga@serveur:~$ 
        

        Hope this method helps you.
        Regards
        Sorry for my english... I'm french

          Pherinos i already tried the same but it didnt work for me because flarum installation calls the php of the system and not the specific location. Since, i am using a shared hosting, the system default php version is 7.0 which was creating the issue

            jahangir I see, on a shared hosting you are dependent on the subscription. I'm with a dedicated physical server and I can choose, with Plesk, which PHP engine Apache will use. It's only with SSH login where I'm dependant of the default PHP version. If there is multiple PHP versions on your shared hosting, have you any administrative interface to setup the PHP version to use with the web server ?

              jahangir You may need to contact your host to get help with how to set the correct php version for Flarum to use. At minimum, you need PHP 7.1+ to work in the folder Flarum is installed in, it's also best if you can access the PHP 7.1+ executable to use in CLI for composer commands.

              If you can't set the latter, you can use --ignore-platform-reqs to force Composer commands on a server where the terminal versions are in conflict with the webserver versions. But only do this if you're absolutely certain, because it will ignore checks for all requirements not just php.

                Pherinos Yes i can choose php version from cpannel for my hosting but again that does not change the system php version ( as i have shared hosting). However, what i did was, i changed the default php version of my hosting from cpanel, then i ran the flarum installation and used "--ignore-platform-reqs" at the end of my commands and it worked. The application is running smoothly without any issues.

                  jordanjay29 yes i did use the "--ignore-platform-reqs" and it has installed successfully and working without any issues. I did contact my hosting provider, they helped me in selecting the relevant version of php but what i understand is flarum installation calls for the php version of the system and not your installation folder which was creating issues in installation. Ignoring the php version, installation was successful and running smoothly as i have already selected php 7.1 as default from cpanel. This default cannot be set for the whole system as it is a shared host and the system default is php 7.0

                    jahangir Yes, sometimes it's necessary to force some options, and it's a good thing that Flarum Team realize that ! Most programs on the web are developed for a version and do not take into account backward compatibility.

                    Good news, enjoy ! 😃