5

Composer always installs the latest version of Drupal core, I want 8.6 not 8.7.

How can I achieve this?

  • Did you specify an exact version? – Kevin Jul 8 '19 at 5:12
  • If you mean like this: composer create-project drupal-composer/drupal-project:8.6.17 some-dir --no-interaction this will give an error "Could not find package drupal-composer/drupal-project with version 8.6.17. ", I also change the versions in composer.json e.g. use --no-install and then edit composer.json and run the install - still 8.7.4 at this time. I assume I must be missing something. – Jeff Burnz Jul 8 '19 at 5:29
  • Drupal-project is not the same as core Drupal – Kevin Jul 8 '19 at 5:53
6

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

| improve this answer | |
4

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>

| improve this answer | |
0

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"
            }
        }
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.