0

We have a CentOS Linux 7 server with Plesk running several Drupal 7 and a few Drupal 8 sites.

Drush commands work fine on all D7 sites, but on all D8 sites any Drush command returns:

PHP Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /var/www/path/to/drupal8site/httpdocs/vendor/symfony/var-dumper/Resources/functions/dump.php on line 18

Running drush status on any D7 site returns a standard report:

 Drupal version                  :  7.65                                                                                      
 Site URI                        :  http://default                                                                            
 Database driver                 :  mysql                                                                                     
 Database hostname               :  localhost                                                                                 
 Database username               :  dbusername                                                                                  
 Database name                   :  dbname                                                                                  
 Database                        :  Connected                                                                                 
 Drupal bootstrap                :  Successful                                                                                
 Drupal user                     :                                                                                            
 Default theme                   :  themename                                                                                  
 Administration theme            :  seven                                                                                     
 PHP executable                  :  /opt/plesk/php/7.1/bin/php                                                                
 PHP configuration               :  /opt/plesk/php/7.1/etc/php.ini                                                            
 PHP OS                          :  Linux                                                                                     
 Drush script                    :  /root/.config/composer/vendor/drush/drush/drush.php                                       
 Drush version                   :  8.1.17                                                                                    
 Drush temp directory            :  /tmp                                                                                      
 Drush configuration             :                                                                                            
 Drush alias files               :  /var/www/path/to/drupal7site/httpdocs/sites/default/example.aliases.drushrc.php 
 Install profile                 :  minimal                                                                                   
 Drupal root                     :  /var/www/vhosts/pinnbank.chronosdv.com/httpdocs                                           
 Drupal Settings File            :  sites/default/settings.php                                                                
 Site path                       :  sites/default                                                                             
 File directory path             :  sites/default/files                                                                       
 Temporary file directory path   :  /tmp                                                                                      

Running drush status on a D8 site returns the PHP Parse error described above.
My research has indicated that there is a disagreement about which PHP version Drush should be using.
I have tried multiple variations of export DRUSH_PHP=/opt/plesk/php/7.1/bin/php but nothing I do seems to make any headway.

Does anyone have any ideas about what to try next?

  • you need drush >8.3 . docs.drush.org/en/master/install – xaa Oct 8 '19 at 0:56
  • 5
    Drush version issue. The Drush for D7 does not work for D8 and vise versa. See the compatibility chart. Rather than have one global Drush, you'll need to install the corresponding version of Drush locally/per project folder. – No Sssweat Oct 8 '19 at 2:24
  • Thanks for the good advice. I confirmed the Drupal 8 site already has vendor/drush/drush/drush and vendor/bin/drush. The Drush version there is drush_version=9.7.1. I installed Drush Launcher following the instructions (github.com/drush-ops/drush-launcher). But if I try to run any Drush command from the Drupal 8 directory (e.g. vendor/bin/drush status I get the same PHP error I was getting before. printenv shows DRUSH_PHP=/opt/plesk/php/7.1/bin/php. php -v shows PHP 5.4.16 (cli), which I suspect is the problem now. Not sure how to override that. Thoughts? – Max Donnelly Oct 8 '19 at 22:37
  • The problem is Drush Launcher ignores the DRUSH_PHP env setting. I got it working with a "workaround". I modified my .bashrc file by adding alias drupal8site-drush='/opt/plesk/php/7.1/bin/php /var/www/vhosts/drupal8site.com/httpdocs/vendor/bin/drush'. Now commands starting with drupal8site-drush in that directory run. The downside: I'll need to create an alias like this for each Drupal 8 site on the server. Fortunately, this server is a temporary solution for a few sites as we migrate D7 to D8. – Max Donnelly Oct 8 '19 at 22:58

Your Answer

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

Browse other questions tagged or ask your own question.