I have a Drupal 8 site up and running with modules that were manually installed. I want to generate an appropriate composer.json file to manage these using Composer.

The closest I could find to achieve this is an old Drupal 7 module, Composer Generate, mentioned in how to install package via composer? but that only works with Drupal 7 and it isn't any longer developed.

How to move Composer created folder of drupal-8.x.x up one level to html? suggests that third-party modules can/should be handled with Composer, but I would like to not have to manually rewrite the composer.json file to achieve this.

Is there a Drupal 8 / Composer / Drush way to accomplish this, or is manually updating the composer.json the only option?


Composer Generate is a Drush extension. It can be used either with Drupal 7 or Drupal 8. Considering that the latest release available on drupal.org is dated Febrary 25, 2016, it's probable it is not compatible with the Drush version you would be use on your site.

The project page for Composer Generate suggests using the Composerize module, which is available for Drupal 8.

This module can generate a composer.json from your installed Drupal code base, which can be used to regenerate that code base by running composer install.

Be careful of the warning reported in the project page.

This module is still in development. It supports very basic Drupal 8 setups, but there are many necessary features it still lacks (e.g., support for patches, JavaScript libraries, distributions, etc). We're working on all that stuff, but this module is definitely not ready for prime time.

The module is supported by Acquia, and the development version has been updated on March 20, 2018.

Alternatively, as the project page suggests, you could use Composerize Drupal, a Composer plugin for converting a non-Composer-managed Drupal site to a Composer-managed Drupal site.

  • thank you again @kiamlaluno - exactly what I was looking for! – rwcorbett Feb 19 at 19:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.