At DrupalCon Global 2020, Moshe Weitzman, Senior Architect and Project Lead at Tag1, and the creator of Drush (the Drupal Command Line), presented his case for a more robust command line tool for Drupal administration. Many Drupal developers and website builders rely on command line tools to get their work done.
Drupal core today
The command line options in Drupal core are implemented as Symfony console commands, and have limited usage compared to similar commands available in Drush.
There are several issues with the core commands -
DbDumpCommand is only for MySQL and does not include
--extra-dump. InstallCommand is Sqlite only, without support for multisite or install profile fields.
Moshe’s proposal is to use a Composer-based approach to add Drush to every Drupal website by including it in the drupal/core-recommended/ project for Drupal 9. Current Drupal core commands remain Symfony Console commands and exist for testing core. This maintains the existing framework, while adding highly useful commands for general development work.
Adding Drush to the core-recommended project gives people the choice of starting with a plain Drupal core installation, or making the choice to use the community’s recommended modules and tools.
Why this works
Moshe presents a number of reasons why this proposal is an improvement for the community:
- Improves the out-of-the-box experience by providing a robust command line for all sites.
- When Drush is part of the package, Drupal documentation can be consistent, especially for installation.
- Contrib and core developers will have confidence when they ship with Drush commands. There’s no confusion between deciding which commands to write: Drupal console, Symfony console, or Drush commands.
- All sites can monitor their non-Drupal dependencies by using a standardized package. Drush ships with
pm:security-php, enabling website owners and developers to quickly see when PHP versions are insecure and need updates.
- The new
deploycommand standardizes Drupal deployment. This command applies a best practice to deployment, making Drupal adoption quicker and easier.
- Adding Drush to
core-recommendedleverages 10+ years of development as part of standard Drupal.
What to consider
While these items are far from downsides, they must be considered as part of this effort:
- The Drush team would need to coordinate with Release Management. This happens already, and would not be a real change.
- Security Team coordination is also imperative. Moshe is on the security team, so this work already happens.
- Core and Drush have separate issue queues and repos. While some may want everything in the same queue, keeping the queues separated helps keep issues focused.
- Drush is functionally tested for many installation permutations (PHP version, Drupal core version, DB backend, etc.) It’s tested with a real Drupal installation, not a mocked test case.
- Developers who want to create sites without this tool can easily opt-out by using
composer remove drush/drush.
Adding Drush to
core-recommended may help projects by enabling them to add their module commands to Drush core. It would enable Drush commands to be more easily added to core modules.