• Stars
    star
    125
  • Rank 285,539 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert a non-Composer-managed Drupal application (e.g., one created via tarball) to a Composer-managed Drupal application.

Build Status Coverage Status Packagist

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 and composer.lock files
  • Generate a new composer.json in the [composer-root] directory based on template.composer.json.
    • Populate require with entries for drupal/core-recommended and drupal/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 to extra 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:
  • 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 generate composer.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 where composer.json will be generated. This should be the root of your Git repository, where .git is located.
  • --drupal-root: Specifies the Drupal root directory where index.php is located.
  • --no-update: Prevents composer update from being automatically run after composer.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 in composer.json, rather than using the default caret operator. E.g., a drupal/core would be required as 8.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.

More Repositories

1

yaml-expander

Expands internal property references in a yaml file.
PHP
154
star
2

expander

This tool expands property references in PHP arrays.
PHP
136
star
3

yaml-cli

A command line tool for reading and manipulating yaml files.
PHP
22
star
4

xdebug-toggle

Simple CLI tools to toggle xdebug easily.
PHP
16
star
5

drupal8to9-upgrade

PHP
12
star
6

drupal-issue-chrome

A chrome extension that renders links to Drupal.org issues based on issue status.
JavaScript
8
star
7

drupal-security-warning

PHP
7
star
8

drupal-composer-training

How to build a Drupal site with Composer AND keep all of your hair! DrupalCon Nashville 2018
6
star
9

drupal-views-itunes-rss

Drupal 8 module for providing <itunes:*> tags via Views RSS.
PHP
6
star
10

project-browser

A project browser embedded in the Drupal UI.
JavaScript
6
star
11

drupal-usasearch

The USASearch module for Drupal.
PHP
5
star
12

composer-scaffold

Allows Composer to copy files around after package installation.
PHP
5
star
13

drupal-module-evaluator

PHP
4
star
14

symfony-console-checklist

A utility for creating animated spinners via Symfony Console.
PHP
2
star
15

drupal7-starter-kit

1
star
16

drupal-table-of-contents

Fork of table_of_contents module.
1
star
17

migrate_html

Example module for migrating static HTML to Drupal
PHP
1
star
18

transcript-analyzer

PHP
1
star
19

artifice

PHP
1
star
20

Fivestar-Node-Settings-Patch

Patch for Drupal 6's Fivestar module-- will allow enabling/disabing fivestar for specific nodes
JavaScript
1
star
21

drupal-gov-features

An assortment of Drupal features for government websites.
HTML
1
star
22

drupal-og-fpp

Organic Groups Fieldable Panels Panes
PHP
1
star