This is an experimental Drush extension that will generate a composer.json file from an existing Drupal project.


drush dl composer_generate

Usage: (Clone a site, no config--Drupal 7 only)

drush @site composer-generate > composer.json
composer install
cd htdocs
drush -y core-quick-drupal

Usage: (Create a new site using composer-project--Drupal 7 or 8)

composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
cd some-dir
drush composer-generate @site
composer install
cd web
drush -y core-quick-drupal


If composer install fails with errors, you may need to fiddle with the generated composer.json file yourself until you arrive at a working version.


Only modules downloaded from will be included in the composer.json file; for custom modules, and other modules taken from other sources, you will have to hand-edit the file and add in the appropriate repository and require entries.

The composer.json file that is generated assumes that the Drupal project root is located in a folder called 'htdocs'. If you want to use another layout, get a composer.json from another source (e.g. drupal-composer/drupal-project) and run drush composer-generate from the directory that contains the composer.json file.

Do NOT use this on the composer.json that comes with Drupal 8, or with the composer.json in the Drupal 8 core directory.

Work in progress; bugs may exist.

Project Information