This project template should provide a kickstart for managing your site dependencies with Composer.
If you want to know, how to use it as replacement for Drush Make visit the Documentation on drupal.org.
First you need to install composer.
Note: The instructions below refer to the global composer installation. You might need to replace
composer
withphp composer.phar
(or similar) for your setup.
After that you can create the project:
composer create-project drupal-composer/drupal-project:7.x-dev some-dir --stability dev --no-interaction
With composer require ...
you can download new dependencies to your installation.
cd some-dir
composer require "drupal/ctools:~1.12"
When installing the given composer.json
some tasks are taken care of:
- Drupal will be installed in the
web
-directory. - Modules (packages of type
drupal-module
) will be placed inweb/sites/all/modules/contrib/
- Theme (packages of type
drupal-module
) will be placed inweb/sites/all/themes/contrib/
- Profiles (packages of type
drupal-profile
) will be placed inweb/profiles/
- Libraries (packages of type
drupal-library
) will be placed inweb/sites/all/libraries/
(See Libraries)
You may add a patch so you don't need to maintain separate a modified module or theme to get faster a fix or make a critical change for your project. Add in composer.json
as in the example.
"extra": {
"patches": {
"drupal/drupal": {
"Add startup configuration for PHP server": "https://www.drupal.org/files/issues/add_a_startup-1543858-30.patch"
}
}
}
Libraries normally would be extra packages that need to be public available (CSS and JS).
Normally this are not maintained using Composer, but if you want to have a 100% Composer deployment and benefit from patches you can use in composer.json
this example, changing the repositories
section and adding in require
section:
"repositories": {
...
"slick": {
"type": "package",
"package": {
"name": "kenwheeler/slick",
"version": "1.6.0",
"dist": {
"url": "https://github.com/kenwheeler/slick/archive/1.6.0.zip",
"type": "zip"
},
"source": {
"url": "https://github.com/kenwheeler/slick.git",
"type": "git",
"reference": "1.6.0"
},
"type": "drupal-library"
}
}
},
"require": {
...
"kenwheeler/slick": "~1.6.0"
},
After this run composer update --lock
to install just the manually managed package.
(You may run composer require "kenwheeler/slick:~1.6.0"
as well if you add just the package definition)
Composer recommends no. They provide argumentation against but also workrounds if a project decides to do it anyway.