2

我在 OVH 服务器上一键安装了 Drupal。第一个糟糕的惊喜:我发现安装的 9.1.9 版本需要对 9.2.9 进行安全更新。

第二个坏惊喜:drush默认情况下没有安装。所以我必须先安装composer才能drush使用命令安装:

curl -sS https://getcomposer.org/installer | php

经过一番战斗,composer开始工作了。我安装了drush发出命令:

composer require --dev drush/drush

可能--dev不需要标志。

我看到composer能够通过运行列出drupal的可用更新:

composer show drupal/recommended-project --all
name     : drupal/recommended-project
descrip. : Project template for Drupal 9 projects with a relocated document root
keywords : 
versions : 9.4.x-dev, 9.3.x-dev, 9.3.0-beta2, 9.3.0-beta1, 9.3.0-alpha1, 9.2.x-dev, 9.2.9, 9.2.8, 9.2.7, 9.2.6, 9.2.5, 9.2.4, 9.2.3, 9.2.2, 9.2.1, 9.2.0, 9.2.0-rc1, 9.2.0-beta3, 9.2.0-beta2, 9.2.0-beta1, 9.2.0-alpha1, 9.1.x-dev, 9.1.14, 9.1.13, 9.1.12, 9.1.11, 9.1.10, 9.1.9, 9.1.8, 9.1.7, 9.1.6, 9.1.5, 9.1.4, 9.1.3, 9.1.2, 9.1.1, 9.1.0, 9.1.0-rc3, 9.1.0-rc2, 9.1.0-rc1, 9.1.0-beta1, 9.1.0-alpha1, 9.0.x-dev, 9.0.14, 9.0.13, 9.0.12, 9.0.11, 9.0.10, 9.0.9, 9.0.8, 9.0.7, 9.0.6, 9.0.5, 9.0.4, 9.0.3, 9.0.2, 9.0.1, 9.0.0, 9.0.0-rc1, 9.0.0-beta3, 9.0.0-beta2, 9.0.0-beta1, 9.0.0-alpha2, 9.0.0-alpha1, 8.9.x-dev, 8.9.20, 8.9.19, 8.9.18, 8.9.17, 8.9.16, 8.9.15, 8.9.14, 8.9.13, 8.9.12, 8.9.11, 8.9.10, 8.9.9, 8.9.8, 8.9.7, 8.9.6, 8.9.5, 8.9.4, 8.9.3, 8.9.2, 8.9.1, 8.9.0, 8.9.0-rc1, 8.9.0-beta3, 8.9.0-beta2, 8.9.0-beta1, 8.8.x-dev, 8.8.12, 8.8.11, 8.8.10, 8.8.9, 8.8.8, 8.8.7, 8.8.6, 8.8.5, 8.8.4, 8.8.3, 8.8.2, 8.8.1, 8.8.0, 8.8.0-rc1, 8.8.0-beta1, 8.8.0-alpha1
type     : project
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage : https://www.drupal.org/project/drupal
source   : [git] https://github.com/drupal/recommended-project.git 7f83a471aca47ffaa981bc8cb8a0cf615163ae5b
dist     : [zip] https://api.github.com/repos/drupal/recommended-project/zipball/7f83a471aca47ffaa981bc8cb8a0cf615163ae5b 7f83a471aca47ffaa981bc8cb8a0cf615163ae5b
names    : drupal/recommended-project

support
chat : https://www.drupal.org/node/314178
docs : https://www.drupal.org/docs/user_guide/en/index.html
source : https://github.com/drupal/recommended-project/tree/9.4.x

requires
composer/installers ^1.9
drupal/core-composer-scaffold ^9.4
drupal/core-project-message ^9.4
drupal/core-recommended ^9.4

requires (dev)
drupal/core-dev ^9.4

conflicts
drupal/drupal *

我的问题是我安装drupal/drupal的显然与drupal/recommended-project我看到drupal我需要的升级相冲突。

从 Drupal 9.1.9 升级到 Drupal 9.2.9 的下一步应该是什么?对不起,如果这个问题是微不足道的,但我被大量的文档弄得不知所措。

更新:这是composer.json我在我的主目录中找到的文件:

{
    "require-dev": {
        "drush/drush": "^10.6"
    }
}

UPDATE2:这是composer.json我在 Drupal 根目录中找到的文件:

{
    "name": "drupal/legacy-project",
    "description": "Project template for Drupal 9 projects with composer following drupal/drupal layout",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.9",
        "drupal/core-composer-scaffold": "^9.1",
        "drupal/core-project-message": "^9.1",
        "drupal/core-recommended": "^9.1",
        "drupal/core-vendor-hardening": "^9.1"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "./"
            }
        },
        "installer-paths": {
            "core": [
                "type:drupal-core"
            ],
            "libraries/{$name}": [
                "type:drupal-library"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/legacy-project template!               </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}
4

2 回答 2

0

如果您的项目是新项目,您可以在 drupal 的最新版本上执行一些操作。为避免任何冲突,您必须:

rm -rf /vendor
rm composer.lock (this file fix the versions of your dependencies)

然后

composer update

它将安装每个依赖项的最新版本。如果您只想更新drupal依赖项(不删除composer.lock和/vendor):

composer update drupal/core-recommended --with-dependencies
于 2021-12-15T16:02:19.973 回答
0

我像这样使用composer/drush/drupal 的初始安装

画笔部分很重要。

作曲家

PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.4.2/bin:$PATH
  php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  php composer-setup.php
  php -r "unlink('composer-setup.php');"
  sudo mv composer.phar /usr/local/bin/composer
  PATH="$(composer config -g home)/vendor/bin:$PATH"

冲刺

cd /drushproject/web/

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

composer global require consolidation/cgr

cgr drush/drush

# correct DrushLog problems (alternatively run once: drush cr)
composer require drush/drush

德鲁巴

drupal --root=/drushproject/web/
于 2021-12-16T14:52:13.117 回答