0

The Server available for our new Drupal project uses an old PHP CLI Version by default. But I have setup an alias in .bash_profile like so:

alias php7=/path/to/php7

and that is working fine. I would like to use Drush, so I cloned the repository, such that I can use Drush with the PHP version from the alias with php7 ./path/to/drush.

Doing so just prints the content of Drush to the terminal.

How can I setup an alias for PHP 7 that allows me to run Drush with that PHP version?

I have added these lines to the .bash_profile file.

alias php7=/path/to/php7
export DRUSH_PHP=/path/to/php7
alias drush="php7 $HOME/path/to/drush.phar"

When I run drush pm-update drupal, I get the following errors.

The external command could not be executed due to an application error.
The command could not be executed successfully
Returned: PHP Parse error: syntax error, unexpected '[' in phar:///path/to/drush.phar/includes/startup.inc on line 63, code: 255)
pm-updatestatus failed.

Why? How can I fix that?

Running drush pm-updatestatus or drush cr works, and drush status shows no errors.

Is there a bug in a specific version?

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Clive
    Commented Nov 14, 2016 at 16:15

1 Answer 1

1

This is possible by setting the environment variable DRUSH_PHP as described in the documentation. https://www.drupal.org/node/1302418

Also you can make use of "php" global otpion which allows to specify the absolute path to PHP interpreter.

4
  • Please see my update…
    – philipp
    Commented Nov 14, 2016 at 9:57
  • What does drush ev 'print PHP_VERSION' print?
    – ya.teck
    Commented Nov 14, 2016 at 10:07
  • 7.0.12 -- as expected…
    – philipp
    Commented Nov 14, 2016 at 10:09
  • does drush use composer? On that server is composer installed, but it uses the wrong php version, so there is an alias composer7=…, too. might that break it?
    – philipp
    Commented Nov 14, 2016 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.