要使用Composer更新Drupal,您只需要将该"drupal/core": "~8.1"
行从replace部分移至require部分。最后,composer.json文件的内容类似于以下内容。
{
"name": "drupal/drupal",
"description": "Drupal is an open source content management platform powering millions of websites and applications.",
"type": "project",
"license": "GPL-2.0+",
"require": {
"composer/installers": "^1.0.21",
"wikimedia/composer-merge-plugin": "~1.3",
"drupal/core": "~8.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"autoloader-suffix": "Drupal8"
},
"extra": {
"_readme": [
"By default Drupal loads the autoloader from ./vendor/autoload.php.",
"To change the autoloader you can edit ./autoload.php."
],
"merge-plugin": {
"include": [
"core/composer.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
}
},
"autoload": {
"psr-4": {
"Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
}
},
"scripts": {
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
"post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
"post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
"post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
},
}
我曾经被用来drush upc
更新Drupal,但是它覆盖了我的composer.json文件和供应商目录。因此,我应该一直运行composer update
以更新供应商目录的内容。
现在,使用Composer更新Drupal,我也可以使用它来下载/更新我正在使用的模块。
我正在使用的composer.json文件是以下文件。
{
"name": "drupal/drupal",
"description": "Drupal is an open source content management platform powering millions of websites and applications.",
"type": "project",
"license": "GPL-2.0+",
"require": {
"composer/installers": "^1.0.21",
"wikimedia/composer-merge-plugin": "~1.3",
"drupal/core": "~8.1",
"drupal/imagick": "8.1.*@dev",
"drupal/mollom": "^8.1",
"drupal/honeypot": "^8.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"autoloader-suffix": "Drupal8"
},
"extra": {
"_readme": [
"By default Drupal loads the autoloader from ./vendor/autoload.php.",
"To change the autoloader you can edit ./autoload.php."
],
"merge-plugin": {
"include": [
"core/composer.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
}
},
"autoload": {
"psr-4": {
"Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
}
},
"scripts": {
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
"post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
"post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
"post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
},
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}
}
}
除了像我说的那样移动那一行,我还执行了以下命令。
composer config repositories.drupal composer https://packagist.drupal-composer.org
composer require drupal/honeypot
composer require drupal/mollom
composer require drupal/imagick 8.1.*@dev
第一个允许我要求Drupal模块并更新它们。
我上次尝试时,Drupal官方存储库仍处于alpha阶段,这给我声明自己为Composer软件包但未设置软件包类型的模块(即drupal-module)带来问题。我希望他们现在解决了这个问题。对于Drupal Packager存储库,以下使用的命令。
composer config repositories.drupal composer https://packages.drupal.org/8
composer require drupal/honeypot
composer require drupal/mollom
composer require drupal/imagick 1.*@dev
如果您已经在使用https://packagist.drupal-composer.org,并且想要替换为官方Packagist网站,则需要将第一个命令替换为composer config repositories.0 composer https://packages.drupal.org/8
,如果您没有其他存储库,则可以使用,这是基于使用packages.drupal.org。
另请注意,packagist.drupal-composer.org计划于2017年1月弃用(或当Drupal.org的官方软件包系统信息库准备就绪时)。
drush up drupal
,我认为这可能会覆盖您的composer.json tho(和其他文件),因此请备份它并在需要时还原。使用composer update