3

My server currently is using PHP 7.1 but I need to run PHP 7.4 during my drush commands on one of my sites. The following works for almost all commands:

/path/to/my/php74 ../vendor/bin/drush cr
/path/to/my/php74 ../vendor/bin/drush cim -y

But when I run the update database command I get an error:

/path/to/my/php74 ../vendor/bin/drush updb -y

or:

export DRUSH_PHP=/path/to/my/php74 && /path/to/my/php74 ../vendor/bin/drush updb -y

I get the following error:

In Process.php line 266:
                                                                                                                                                                      
  The command "/home/releases/74/vendor/drush/drush/drush updatedb:status --yes --no-entity-updates --strict=0 --uri=default --root=/ho  
  me/releases/74/web" failed.                                                                                                            
                                                                                                                                                                      
  Exit Code: 255(Unknown error)                                                                                                                                       
                                                                                                                                                                      
  Working directory:                                                                                                                                                  
                                                                                                                                                                      
  Output:                                                                                                                                                             
  ================                                                                                                                                                    
                                                                                                                                                                      
  Warning: Unsupported declare 'strict_types' in /home/releases/74/vendor/phpstan/phpstan/bootstrap.php on line 1                        
                                                                                                                                                                      
  Parse error: syntax error, unexpected ':', expecting ';' or '{' in /home/releases/74/vendor/phpstan/phpstan/bootstrap.php on line 12   
                                                                                                                                                                      
                                                                                                                                                                      
  Error Output:                                                                                                                                                       
  ================                                                                                                                                                    
                            

I'm guessing during the updb command it calls another command but it doesn't retain my php version.

2 Answers 2

1

I was able to run drush cr and drush cim using a specific php version via the command:

/opt/cpanel/ea-php74/root/bin/php ~/public_html/vendor/bin/drush cr and

/opt/cpanel/ea-php74/root/bin/php ~/public_html/vendor/bin/drush cim

This was not working, though, to run drush updb for which I was getting the error mentioned in my other post:

Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.31.

I could make the command line use php7.4 also for drush updb by exporting the PATH variable first with:

export PATH=/opt/cpanel/ea-php74/root/bin:$PATH:$HOME/bin

Then running drush updb normally.

1
  • THIS! I was getting crazy because of this and I was always making a silly mistake: I included the whole path to the binary file into PATH and that's wrong. You just have to put in the path, without the binary. Sep 29, 2022 at 16:01
0

Maybe the configuration of your composer.json depends of old php-version, so your php-code is not fresh. Check it.

And... There is useful tool for using many versions of PHP on one computer - PhpBrew. You can try it for your software upgrade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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