web-dev-qa-db-fra.com

Comment installer une version spécifique de Drupal en utilisant Composer

Composer installe toujours la dernière version de Drupal core, je veux 8.6 pas 8.7.

Comment puis-je atteindre cet objectif?

3
Jeff Burnz

Créer un projet drupal avec l'option --no-install:

composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction --no-install

Remplacez les répertoires par my_site_name_dir et modifiez les contraintes de version dans le fichier composer.json:

"require": {
    ...
    "drupal/core": "8.6.*",
    ...
},

Aussi pour

"require-dev": {
    "webflo/drupal-core-require-dev": "8.6.*"
},

webflo/drupal-core-require-dev fournit les dépendances require-dev de drupal/core en tant que package autonome. Il suit le même cycle de version et le même schéma de version que Drupal core. Vous devez utiliser la même contrainte de version que celle utilisée pour Drupal core.

Courir composer install

4
4k4

Mon erreur n'était pas de définir la bonne version de webflo/drupal-core-require-dev le long de la version drupal/core, donc composer.json devrait ressembler à ceci:

{
    "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"
            }
        }
    }
}
0
Jeff Burnz