Make it possible to use specific PHP binary with console

Hello!

We have a server that needs to run PHP5.4 but also runs Piwik. So, Piwik is running with nginx/PHP7.0-fpm and is than proxied to apache2.

Today I needed to create a new site and wanted to import the access logs from the last 14 days. Well, it was not possible because the importer uses php and not php7.0. I fixxed this issue by altering the importer to use php7.0 binary (line 971).

The problem now lies in the console. There is no possibility to define my own binary (I found none). It would be nice, to:

a) Automaticly search for php7.0 and php7.1 if php links to php5.4
or
b) Beeing able to choose my own binary via cli option (this option is only valid, if I’m able to run the help with php5.4. Currently I’m not able to do this!)

Greetings from Germany
Fabian

Maybe I am missing something obvious here, but can’t you just run the console file with the php binary you want? So php7.0 ./console should work as console is just a normal php script.

You are indeed correct. If you change #!/usr/bin/env php to #!/usr/bin/env php7.0 the console will run again. Option a) would still be nice to have.

There is already a version_compare() included. Should not be a big problem to first look for php7.X if 5.5.9 or 5.6 not found.

While I am not sure if it is possible for a php script to select which binary it will be run with, it would be definitely a nice feature to warn the user if the console is run with the ‘wrong’ php version.

I just noticed that I may have misunderstood you. Are you talking about the php cli (so ./console) or the python log importer (misc/log-analytics/import_logs.py)?