Convert a non-Composer managed Drupal application into a Composer-managed application.
Composerize Drupal is a Composer plugin that converts a non-Composer-managed Drupal application (e.g., one created via tarball) to a Composer-managed Drupal application.
It is not for creating new Drupal applications. If you want to create a brand new Drupal application, use drupal-project instead.
composerize-drupal command will perform the following operations:
- Remove all vestigial
- Generate a new
[composer-root]directory based on template.composer.json.
requirewith entries for
requirewith an entry for each project in:
- Require and configure suggested Composer plugins:
drupal/composer-scaffoldfile paths to
extraconfiguration to ensure that Drupal projects are downloaded to the correct locations.
- Create and populate
extra.patchesobject to facilitate patching with Composer Patches. Patches to profiles, themes, and modules will be automatically discovered and moved to the a new [repo-root]/patches directory.
- Add entries to
https://packages.drupal.org/8for installing packages from Drupal.org
https://asset-packagist.org/to permit installing NPM packages.
- Create or modify
[composer-root]/.gitignorewith entries for Composer-managed contributed projects as per best practices. You can modify
.gitignoreafter composerization if you'd prefer not to follow this practice.
composer updateto generate
composer.lock, autoload files, and install all dependencies in the correct locations.
It will NOT add any contributed projects in
composer.json. You must add those to your
composer.json file manually. In addition to packagist and Drupal.org packages, you may also use any package from asset packagist, which makes NPM packages available to Composer.
composer global require grasmash/composerize-drupal
cd path/to/drupal/project/repo composer composerize-drupal --composer-root=[repo-root] --drupal-root=[drupal-root]
[composer-root] should be the root directory of your project, where
.git is located.
[drupal-root] should be the Drupal root, where
index.php is located.
# Drupal is located in a `docroot` subdirectory. composer composerize-drupal --composer-root=. --drupal-root=./docroot # Drupal is located in a `web` subdirectory. composer composerize-drupal --composer-root=. --drupal-root=./web # Drupal is located in a `public_html` subdirectory (cPanel compatible). composer composerize-drupal --composer-root=. --drupal-root=./public_html # Drupal is located in the repository root, not in a subdirectory. composer composerize-drupal --composer-root=. --drupal-root=.
--composer-root: Specifies the root directory of your project where
composer.jsonwill be generated. This should be the root of your Git repository, where
--drupal-root: Specifies the Drupal root directory where
composer updatefrom being automatically run after
--no-gitignore: Prevents modification of the root .gitignore file.
--exact-versions: Will cause Drupal core and contributed projects (modules, themes, profiles) to be be required with exact verions constraints in
composer.json, rather than using the default caret operator. E.g., a
drupal/corewould be required as
^8.4.4. This prevents projects from being updated. It is not recommended as a long-term solution, but may help you convert to using Composer more easily by reducing the size of the change to your project.