Composer is a powerful dependency management tool for PHP, designed to simplify the process of installing and managing libraries and packages required for your projects. As an open-source platform built on PHP, Drupal leverages Composer to streamline its installation and dependency management. This article will guide you through the steps to install Drupal using Artifactory, ensuring a smooth and efficient setup process.
Create PHP composer Repositories in the Artifactory
In order to successfully install Drupal with all the dependencies, we need two remote repositories.
1. Create a PHP Composer remote repository(php-drupal) for drupal with the below information:
URL : https://ftp.drupal.org/ Registry URL : https://packages.drupal.org/8
2. Create another PHP Composer repository(php-default) for other dependencies
URL : https://github.com Registry URL : https://packagist.org/
3. Create a virtual PHP Composer repository(drupal-virtual) and aggregate the above two repositories.
Configure the Composer Client to Work with Artifactory
1. Set up config.json
{
"repositories": [{
"type": "composer",
"url": "https://ARTIFACTORY_HOST/artifactory/api/composer/drupal-virtual"
},
{
"packagist": false
}
]
}
2. Set up auth.json
{
"http-basic": {
"ARTIFACTORY_HOST": {
"username": "<user>",
"password": "<token>"
}
}
}
Install Drupal
Drupal can be installed using the sample code found here. Feel free to change the branch according to your preferred version.
Composer.json:
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 10 projects with Composer",
"license": "GPL-2.0-or-later",
"type": "project",
"authors": [
{
"name": "",
"role": ""
}
],
"require": {
"composer/installers": "^2.0",
"drupal/admin_toolbar": "^3.4",
"drupal/apigee_api_catalog": "^3.0",
"drupal/apigee_edge": "^3.0",
"drupal/better_exposed_filters": "^6.0",
"drupal/bootstrap5": "^4.0",
"drupal/components": "^3.0@beta",
"drupal/core-composer-scaffold": "^10.3",
"drupal/core-project-message": "^10.3",
"drupal/core-recommended": "^10.3",
"drupal/devel": "^5.2",
"drupal/easy_breadcrumb": "^2.0",
"drupal/email_registration": "^2.0@RC",
"drupal/field_group": "^3.6",
"drupal/formdazzle": "^3.0",
"drupal/graphql": "^4.8",
"drupal/paragraphs": "^1.17",
"drupal/pathauto": "^1.12",
"drupal/swagger_ui_formatter": "^4.1",
"drupal/twig_tweak": "^3.4",
"drupal/viewsreference": "^2.0@beta",
"drupal/webform": "^6.2",
"drush/drush": "^12.5"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "stable",
"prefer-stable": true,
"config": {
"allow-plugins": {
"composer/installers": false,
"drupal/core-composer-scaffold": false,
"php-http/discovery": true,
"drupal/core-project-message": true
}
}
} Commands:
composer clearcache composer install
Sample snippet from the Installation:
- Downloading phootwork/collection (v3.2.2) - Downloading phpowermove/docblock (v4.0) - Downloading consolidation/output-formatters (4.5.0) - Downloading consolidation/annotated-command (4.10.0) - Downloading consolidation/robo (4.0.6) - Downloading consolidation/filter-via-dot-access-data (2.0.2) - Downloading chi-teck/drupal-code-generator (3.6.1) - Downloading drush/drush (12.5.3) - Installing composer/installers (v2.3.0): Extracting archive - Installing php-http/discovery (1.19.4): Extracting archive - Installing drupal/core-composer-scaffold (10.3.5): Extracting archive - Installing drupal/core-project-message (10.3.5): Extracting archive - Installing symfony/polyfill-mbstring (v1.29.0): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.29.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.29.0): Extracting archive - Installing symfony/polyfill-ctype (v1.29.0): Extracting archive - Installing symfony/string (v6.4.12): Extracting archive - Installing symfony/deprecation-contracts (v3.5.0): Extracting archive - Installing psr/container (2.0.2): Extracting archive
Reference:
Set up Remote repositories
Using composer to install Drupal