When I try to use any grav command via SSH I get an error like this:
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or ‘(’ in /…/grav/bin/grav on line 9
I guess it has to do with the fact that my hosts default is an old cli version of PHP.
It’s possible to use a different version, eg:
/usr/local/bin/php7-70STABLE-CLI
or
/usr/local/bin/php5-56STABLE-STANDARD
But I don’t know if
a) this realli is the reason for the error
and
b) if so, what I had to for grav to use another version
Any hints would be greatly appreciated. As I’m not a console guy I’m looking forward for a way that helps me do what I have to do to get access to the grav cli. So I can begin to understand.
First check which version of php you are running by default:
$ php -v
If it’s the wrong version, you just need to put the path to the PHP binary in your path, before the regular one. This usually means, putting the explicity PHP7 bin path at the front of your path variable. Depending on your platform, and OS, this is going to require some googling. For example on a linux-based system that is running Bash shell, you would add it to the front of path variable in .bashrc
Depending on the host, I find it easier to check if their PHP versions are just renamed executables. For example, my host uses php70 for PHP v7, so I can just substitute it for php.
I don’t want to execute any php-commands directly but grav commands which obviously depend on a minima php version. I still don’t get how I execute something like
bin/gpm selfupgrade
Where can I set the correct php version to execute?
You should ask your host. There are usually command aliases when multiple versions are available, as for example when I do the same I do not need the executable path but just php70 bin/gpm selfupgrade.