Composer always installs the latest version of Drupal core, but I want Drupal 8.6, not Drupal 8.7.
How can I install a specific core version?
Composer always installs the latest version of Drupal core, but I want Drupal 8.6, not Drupal 8.7.
How can I install a specific core version?
Now Drupal recommended project supports version as command line option. If you want to install version 8.8.5 via Composer then command will like as shown below.
composer create-project drupal/recommended-project:8.8.5 <INSTALL_DIR>
Create drupal-project with --no-install option:
composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction --no-install
Change directories to my_site_name_dir and edit the version contraints in the composer.json file:
"require": {
...
"drupal/core": "8.6.*",
...
},
Also for
"require-dev": {
"webflo/drupal-core-require-dev": "8.6.*"
},
webflo/drupal-core-require-dev provides the require-dev dependencies of drupal/core as a standalone package. It follows the same release cycle and versioning scheme as Drupal core. You should use the same version constraint for it as you use for Drupal core.
Run composer install
Since answering the question the de-facto standard for installing Drupal via composer has changed from drupal-composer/drupal-project to drupal/recommended-project. Now you can append the version directly to the package. See Vinod Singh's answer.
My mistake was not setting the correct webflo/drupal-core-require-dev version along it the drupal/core version, so composer.json should look like this:
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"php": ">=5.6",
"composer/installers": "^1.2",
"cweagans/composer-patches": "^1.6.5",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/console": "^1.0.2",
"drupal/core": "8.6.17",
"drush/drush": "^9.0.0",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"require-dev": {
"webflo/drupal-core-require-dev": "8.6.17"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
],
"files": ["load.environment.php"]
},
"scripts": {
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/{$name}": ["type:drupal-drush"]
},
"drupal-scaffold": {
"initial": {
".editorconfig": "../.editorconfig",
".gitattributes": "../.gitattributes"
}
}
}
}