Drush 8 installatie

Uit De Vliegende Brigade
Ga naar: navigatie, zoeken

Nieuwe Drupal, nieuwe Drush

De versie van Drush die werkt met Drupal 6 en 7, werkt niet met Drupal 8:

drush
PHP Fatal error:  Class 'Drupal\Core\Session\AccountInterface' not found in /var/www/example.com/public/core/includes/bootstrap.inc on line 66
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                    [error]
Error: Class 'Drupal\Core\Session\AccountInterface' not found in /var/www/example.com/public/core/includes/bootstrap.inc, line 66

Deze foutmelding kan trouwens ook onder andere omstandigheden opreden. Zie verderop.

Versies van Drush

Drush Version 	Branch 	PHP 	Compatible Drupal versions 	Code Status
-------------   ------  ------  --------------------------      ---------------
Drush 9 	master 	5.6+ 	D8                              Build - Passing
Drush 8 	8.x 	5.4.5+ 	D6, D7, D8 	                Build - Passing
Drush 7 	7.x 	5.3.0+ 	D6, D7 	 	                Build - Passing
Drush 6 	6.x 	5.3.0+ 	D6, D7 	 	                Build - Passing
Drush 5 	5.x 	5.2.0+ 	D6, D7 	                        Unsupported
Drush 4 	4.x 	5.2.0+ 	D5, D6, D7 	                Unsupported
Drush 3 	3.x 	5.2.0+ 	D5, D6 	                        Unsupported

Bron

Installatie - recommended (feb. 2017)

Dit is wat de officiele site zegt:

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush-unstable.phar');" > drush

# Test your install.
php drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init

En dat werkt prima. /usr/local/bin was al opgenomen in de $PATH-variabele, maar het werkte pas na herstarten van de computer (uit- en inloggen had wellicht ook geholpen).

Installatie mbv. Composer

Drupal 8 gebruikt Composer voor installatie van PHP-projecten. Installatie Drush 8 middels Composer gaat met het commando:

composer global require drush/drush:dev-master

Output:

Changed current directory to /home/strompf/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files

In de home-directory is nu een boom aan mappen en bestanden geplaatst onder .composer, inclusief mappen voor Drush.

PATH-variabele bijwerken

Voeg toe aan .bashrc:

export PATH="$HOME/.composer/vendor/bin:$PATH"

en ververs de inhoud van .bashrc: source .bashrc. Het is belangrijk dat het nieuwe pad vóór het bestaande pad wordt ingevoerd: Anders zal-ie de oude Drush-instantie eerder vinden dan de nieuwe!

Test

Test Drush met commando

drush status

De eerste paar regels van de uitvoer, half oktober 2015:

 Drupal version                  :  8.0.0-rc1                                                                                                  
 Site URI                        :  http://default                                                                                             
 Database driver                 :  mysql                                                                                                      
 Database hostname               :  localhost                                                                                                  
 Database port                   :  3306    
 ...

Hieronder is de complete uitvoer van drush status, begin 2015. Dit betreft een situatie waarin de Drupal core-bestanden zijn geplaatst, maar er nog geen functionerende site is:

 Drupal version         :  8.0.0-rc3                                            
 PHP executable         :  /usr/bin/php                                         
 PHP configuration      :  /etc/php5/cli/php.ini                                
 PHP OS                 :  Linux                                                
 Drush script           :  /home/strompf/.composer/vendor/drush/drush/drush.php 
 Drush version          :  8.0-dev                                              
 Drush temp directory   :  /tmp                                                 
 Drush configuration    :                                                       
 Drush alias files      :                                                       
 Drupal root            :  /var/www/drush8test

Casus okt. 2015: Git not found

Commando composer global require drush/drush:dev-master gaf andere output dan tijdens eerdere installatie:

Changed current directory to /home/strompf/.composer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing jakub-onderka/php-console-color (0.1)
    Downloading: 100%         

  - Installing jakub-onderka/php-console-highlighter (v0.3.2)
    Downloading: 100%         

  - Installing dnoegel/php-xdg-base-dir (0.1)
    Downloading: 100%         

  - Installing nikic/php-parser (v1.4.1)
    Downloading: 100%         

  - Installing symfony/var-dumper (v2.7.5)
    Downloading: 100%         

  - Installing symfony/console (v2.7.5)
    Downloading: 100%         

  - Installing psy/psysh (v0.5.2)
    Downloading: 100%         

  - Installing pear/console_table (1.2.1)
    Downloading: 100%         

  - Installing symfony/yaml (v2.7.5)
    Downloading: 100%         

  - Installing drush/drush (dev-master 4017fe6)
    Cloning 4017fe6b80b1e58137f98c82ae0cf3ff8fcfa8d1
    Failed to download drush/drush from source: Failed to clone git@github.com:drush-ops/drush.git, git was not found, check that it is installed and in your PATH env.

sh: 1: git: not found

    Now trying to download from dist
  - Installing drush/drush (dev-master 4017fe6)
    Downloading: 100%         

symfony/var-dumper suggests installing ext-symfony_debug ()
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/process ()
symfony/console suggests installing psr/log (For using the console logger)
psy/psysh suggests installing ext-readline (Enables support for arrow-key history navigation, and showing and manipulating command history.)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
pear/console_table suggests installing pear/Console_Color2 (>=0.1.2)
drush/drush suggests installing drush/config-extra (Provides configuration workflow commands, such as config-merge.)
Writing lock file
Generating autoload files

... Maar Drush bleek gewoon te werken en te zijn bijgewerkt.

Zie ook

Bronnen