grasmash / composerize-drupal
Convert a non-Composer managed Drupal application into a Composer-managed application.
Installs: 19 106
Dependents: 1
Suggesters: 0
Security: 0
Stars: 125
Watchers: 8
Forks: 20
Open Issues: 9
Type:composer-plugin
Requires
- php: >=5.6
- composer-plugin-api: ^2.0
- composer/semver: ^3
- symfony/finder: ^3.4
- symfony/yaml: ^3.4
- webflo/drupal-finder: ^1.1
- webmozart/path-util: ^2.3
Requires (Dev)
- alchemy/zippy: ^0.4.8
- composer/composer: ^2.0
- phpunit/phpunit: ^5.7
- satooshi/php-coveralls: ^2.0
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2024-10-20 00:36:24 UTC
README
Composerize Drupal
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.
Functionality
The composerize-drupal
command will perform the following operations:
- Remove all vestigial
composer.json
andcomposer.lock
files - Generate a new
composer.json
in the[composer-root]
directory based on template.composer.json.- Populate
require
with entries fordrupal/core-recommended
anddrupal/core-composer-scaffold
- Populate
require
with an entry for each project in:[drupal-root]/modules
[drupal-root]/modules/contrib
[drupal-root]/themes/contrib
[drupal-root]/profiles/contrib
- Require and configure suggested Composer plugins:
- Add
drupal/composer-scaffold
file paths toextra
configuration to ensure that Drupal projects are downloaded to the correct locations. - Create and populate
extra.patches
object 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
repositories
:https://packages.drupal.org/8
for installing packages from Drupal.orghttps://asset-packagist.org/
to permit installing NPM packages.
- Add
- Populate
- Create or modify
[composer-root]/.gitignore
with entries for Composer-managed contributed projects as per best practices. You can modify.gitignore
after composerization if you'd prefer not to follow this practice. - Execute
composer update
to generatecomposer.lock
, autoload files, and install all dependencies in the correct locations.
It will NOT add any contributed projects in docroot/libraries
to 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.
Installation
composer global require grasmash/composerize-drupal
Usage:
cd path/to/drupal/project/repo
composer composerize-drupal --composer-root=[repo-root] --drupal-root=[drupal-root]
The [composer-root]
should be the root directory of your project, where .git
is located.
The [drupal-root]
should be the Drupal root, where index.php
is located.
Examples:
# 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=.
Options
--composer-root
: Specifies the root directory of your project wherecomposer.json
will be generated. This should be the root of your Git repository, where.git
is located.--drupal-root
: Specifies the Drupal root directory whereindex.php
is located.--no-update
: Preventscomposer update
from being automatically run aftercomposer.json
is generated.--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 incomposer.json
, rather than using the default caret operator. E.g., adrupal/core
would be required as8.4.4
rather than^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.