This composer plugin can be added to a fully 'composerized' Drupal 9 / 10 / 11 or WordPress site. In order to easily install CiviCRM extensions on it.
This works on a Drupal 9, 10, 11 site based on drupal-composer/drupal-project, So if you have an older Drupal 9 site, you'll need to convert it before using this plugin.
You need a couple of dependencies first:
CiviCRM is required for this plugin.
Put Skvare repository path in composer.json to locate this plugin under
repositories section.
"civicrm-extension-plugin": {
"type": "vcs",
"url": "https://github.com/Skvare/civicrm-extension-plugin"
},
OR
{
"type": "vcs",
"url": "https://github.com/Skvare/civicrm-extension-plugin"
}
Then Run:
composer require civicrm/civicrm-extension-plugin
Configuration require for downloading extensions through the composer.json file:
Example:
"extra": {
"civicrm": {
"extensions_install_path": "./web/sites/default/civicrm/extensions/contrib",
"extensions": {
"org.wikimedia.relationshipblock": {
"url": "https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock/archive/1.3.zip"
},
"uk.co.vedaconsulting.gdpr": {
"url": "https://github.com/veda-consulting-company/uk.co.vedaconsulting.gdpr/archive/v2.7.zip"
},
"uk.co.vedaconsulting.mosaico": {
"url": "https://github.com/veda-consulting-company/uk.co.vedaconsulting.mosaico/archive/2.5.zip"
},
"org.civicrm.shoreditch": {
"url": "https://github.com/civicrm/org.civicrm.shoreditch/archive/1.0.0-beta.2.zip"
},
"org.civicrm.contactlayout": {
"url": "https://github.com/civicrm/org.civicrm.contactlayout/archive/1.7.1.zip"
},
"org.civicrm.angularprofiles": {
"url": "https://github.com/ginkgostreet/org.civicrm.angularprofiles/archive/v4.7.31-1.1.2.zip"
},
"net.ourpowerbase.sumfields": {
"url": "https://github.com/progressivetech/net.ourpowerbase.sumfields/archive/v4.0.2.zip"
},
"org.civicrm.module.cividiscount": {
"url": "https://github.com/civicrm/org.civicrm.module.cividiscount/archive/3.8.1.zip"
},
"ca.civicrm.logviewer" : {
"url": "https://github.com/adixon/ca.civicrm.logviewer/archive/1.2.zip",
"patches": [
"./patches/logviewer.patch"
]
}
}
}
}In the composer extra snippet, we can define civicrm extension path.
The default path is web/sites/default/civicrm/extensions/contrib.
"civicrm": {
"extensions_install_path": "./web/sites/default/civicrm/extensions/contrib",
"composer_exit_on_extensions_patch_failure": true,
"extensions": {
.
.
.
}
You can git ignore the contrib extension path like this in .gitignore file
/web/sites/*/civicrm/extensions/contrib/*
!web/sites/*/civicrm/extensions/contrib/.gitkeep.gitkeep is placeholder empty file.
You can keep your custom extension under web/sites/*/civicrm/extensions/custom/ directory with GIT control.
This plugin supports WordPress sites with CiviCRM. Set cms_type to wordpress in your composer.json to enable WordPress-specific behavior:
"extra": {
"civicrm": {
"cms_type": "wordpress",
"extensions_install_path": "./wp-content/uploads/civicrm/ext/contrib",
"extensions": {
...
}
}
}By default, asset syncing is skipped for WordPress sites. To enable syncing CiviCRM web assets on a WordPress site, specify a custom asset destination path using the civicrm-asset configuration key:
"extra": {
"civicrm": {
"cms_type": "wordpress"
},
"civicrm-asset": {
"path": "wp-content/plugins/civicrm/civicrm"
}
}When civicrm-asset.path is set, the plugin will sync CiviCRM web assets to that path and deploy a WordPress-compatible settings_location.php that automatically searches the following candidate directories for civicrm.settings.php:
uploads/civicrm(up to 4 levels up)wp-content/uploads/civicrm(up to 4 and 3 levels up)civicrm(2 levels up)
If civicrm-asset.path is not set on a WordPress site, asset syncing is skipped entirely (Drupal sites always sync to ./web/libraries/civicrm by default).
How it works:
- We can patch the extension code for downloaded code; you can keep all the patches in the
patchesdirectory. - All contrib extensions will get downloaded at the defined location.
extensions_install_pathincomposer.jsonfile, if it is not mentioned then default path isweb/sites/default/civicrm/extensions/contrib. - Extension also downloaded/refreshed when civicrm core installed or updated action happened through composer.
composer_exit_on_extensions_patch_failureis a boolean value, if set to true then composer will exit with error code if any patch fails to apply or failed to download the extension.- An existing extension directory is only removed after a new zip archive has been successfully downloaded, preventing data loss if the download fails.
Run composer list command, this will show you
civicrm
civicrm:download-extensions Download CiviCRM extensions defined in composer.json
civicrm:publish Publish web assets from CiviCRM-related projects
Run composer civicrm:download-extensions command to download extension.
Use -c, --clean for clean extension directory before downloading extensions.
Example:
Run `composer civicrm:download-extensions -c` command to remove all extension from contrib before download extension.
Output:
composer civicrm:download-extensions -c
> [civicrm-extension-plugin] Cleaning ./web/sites/default/civicrm/extensions/contrib directory...
> [civicrm-extension-plugin] Downloading CiviCRM extension org.wikimedia.relationshipblock from https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock/archive/1.3.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension uk.co.vedaconsulting.gdpr from https://github.com/veda-consulting-company/uk.co.vedaconsulting.gdpr/archive/v2.7.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension uk.co.vedaconsulting.mosaico from https://github.com/veda-consulting-company/uk.co.vedaconsulting.mosaico/archive/2.5.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension org.civicrm.shoreditch from https://github.com/civicrm/org.civicrm.shoreditch/archive/1.0.0-beta.2.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension org.civicrm.contactlayout from https://github.com/civicrm/org.civicrm.contactlayout/archive/1.7.1.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension org.civicrm.angularprofiles from https://github.com/ginkgostreet/org.civicrm.angularprofiles/archive/v4.7.31-1.1.2.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension net.ourpowerbase.sumfields from https://github.com/progressivetech/net.ourpowerbase.sumfields/archive/v4.0.2.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension org.civicrm.module.cividiscount from https://github.com/civicrm/org.civicrm.module.cividiscount/archive/3.8.1.zip...
> [civicrm-extension-plugin] Downloading CiviCRM extension ca.civicrm.logviewer from https://github.com/adixon/ca.civicrm.logviewer/archive/1.2.zip...
> [civicrm-extension-plugin] |-> Applying patch: ./patches/logviewer.patch
> [civicrm-extension-plugin] Syncing CiviCRM web assets to /web/libraries/civicrm...
This also syncs CiviCRM web assets like:
- kcfinder
- extension-compatibility.json
- ck-options.json