This project template provides a starter kit for the Aegir Hostmaster Drupal distribution.
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 aegir/hostmaster-project:dev-master --no-interaction /var/aegir/hostmaster-7.x-4.x
With composer require ...
you can download new dependencies to your
installation.
cd some-dir
composer require drupal/devel:~1.0
The composer create-project
command passes ownership of all files to the
project that is created. You should create a new git repository, and commit
all files not excluded by the .gitignore file.
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) - Helps for using other PHP packages almost similar to the Drupal 8 version
- Creates default writable versions of
settings.php
. - Creates
web/sites/default/files
-directory. - Latest version of drush is installed locally for use at
vendor/bin/drush
.
With using the "Composer Generate" drush extension
you can now generate a basic composer.json
file from an existing project. Note
that the generated composer.json
might differ from this project's file.
The skeleton already installs the composer_autoloader
module. Just enable it in the website before enabling
any possible module that have dependencies various packages.
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": [
...
{
"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.
If you need to apply patches (depending on the project being modified, a pull request is often a better solution), you can do so with the composer-patches plugin.
To add a patch to drupal module foobar insert the patches section in the extra section of composer.json:
"extra": {
"patches": {
"drupal/foobar": {
"Patch description": "URL or local path to patch"
}
}
}
Follow the instructions in the documentation on drupal.org.
This project supports PHP 5.3 as minimum version (see Drupal 7 PHP requirements), however it's possible that a composer update
will upgrade some package that will then require PHP 7+.
To prevent this you can add this code to specify the PHP version you want to use in the config
section of composer.json
:
"config": {
"sort-packages": true,
"platform": {
"php": "5.3.3"
}
},