Drush Boris

Categories

Component ID

2151685

Component name

Drush Boris

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

A Drupal command which integrates the Boris PHP REPL (read-eval-print loop) with Drush.

Boris implements an interactive shell for typing and executing PHP commands. The PHP CLI application has its own which can be started by using the -a option, but Boris is prettier and more robust - php -a will dump you back to the shell if a fatal error occurs, but Boris will keep you in business. This Drush command invokes Boris from within Drush, so Drupal functions and classes (as well as Drush's) are available to you from within the shell without having to go the other way around (bootstrapping Drupal from within Boris) first.

Boris is similar to phpsh, for which there is also a Drush command available; however, phpsh requires Python for whatever reason. Boris is purely PHP; an advantage for resource-limited servers or where you don't want to increase your server's attack surface by installing unnecessary scripting languages.

As this is merely a Drush command and not a full module, don't put it inside a Drupal modules directory - it won't work. Put it inside a Drush commands directory instead. See this documentation for possible directories.

This command requires Drush 5 and greater, and has been tested with Drupal 7 and Drupal 8 sites. Drupal 6 compatibility is currently unknown.

Boris is not included with the download; grab it from its Github page.

ProTip: Exiting Boris when Boris won't exit

You should be able to exit Boris by invoking any PHP command which would normally halt the program, such as exit;. However, I've noticed in some cases fatal exceptions happen when trying to exit, and Boris dutifly catches those exceptions, reports them, then keeps on running. If this happens to you, hit Ctrl-Z to put the job in the background and return to your shell. Then run jobs -l to list suspended jobs along with their process ID, and use kill to kill the process. This has worked for me both in tcsh and bash.