MacBook avec code sur un bureau

Install drupal/console on drupal 9

The drupal/console package was never made fully compatible with Drupal 9, and its development has now stopped. If you are starting a recent project, the command-line reference is now Drush.

The modern solution: Drush

Drush is actively maintained and compatible with Drupal 9, 10 and beyond:

composer require drush/drush

You then access the commands through vendor/bin/drush: code generation, cache management, migrations, and so on.

If you really need drupal/console

For an existing project that still depends on it, installing on Drupal 9 requires a few options passed to Composer to force resolution:

composer require drupal/console:~1.0 
  --prefer-dist 
  --optimize-autoloader 
  --sort-packages 
  --no-update

composer update

Keep in mind that the tool is no longer maintained: this is a workaround, not a long-term base. The original issue is in fact still open.

See also