hussainweb / drupal-composer-helper
与 Drupal 一起使用的常用脚本
Requires
- php: >=5.5.9
- composer-plugin-api: ^1.1
- composer/installers: ^1.2
- symfony/filesystem: ^3.3 || ^4.0
- webmozart/path-util: ^2.3
Requires (Dev)
- composer/composer: ^1.0
- squizlabs/php_codesniffer: ^3.5
Suggests
- cweagans/composer-patches: Allows patching from local and remote patch files.
- drupal/console: The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
- drupal/core: Why are you even using this package, if not to use Drupal?
- drupal/core-composer-scaffold: Scaffold individual files from drupal/core into their desired location.
- drupal/core-vendor-hardening: Removes extraneous directories from the Composer-managed vendor directory.
- drush/drush: Drush is a command line shell and scripting interface for Drupal.
- oomphinc/composer-installers-extender: Extend the composer/installers plugin to accept any arbitrary package type.
This package is auto-updated.
Last update: 2024-09-11 14:38:22 UTC
README
此插件处理基于 composer 的 Drupal 设置的常见操作。此插件中的代码源自 Drupal 代码库本身,以及其他项目,如 drupal-composer/drupal-project。
为什么?
编写此插件背后的动机是使基于 composer 的 Drupal 设置更容易维护。使用 drupal-composer/drupal-project 提供的模板很容易开始,但升级却很困难。该插件通过将所有代码保留在您的项目外,并在插件中,使升级变得像运行 composer update
一样简单,从而解决了这个问题。
安装
如果您正在开始一个新的 Drupal 7 或 8 网站,则可以使用 hussainweb/drupal-composer-init composer 插件更容易地开始。按照那里的说明安装和使用命令。生成的 composer.json 文件 包含此插件。
对于现有的 composer 设置,只需运行此命令
composer require hussainweb/drupal-composer-helper:^1.0
与新的 composer 模板一起使用
待办事项
在 drupal-composer 模板中使用
此插件包含来自 drupal-composer 模板的大部分功能。尽管如此,该插件可以在模板中进行一些更改。这些更改不是运行插件所必需的,但某些操作可能会运行两次。
按照以下步骤在 drupal-composer 模板中使用插件
- 包含插件:
composer require hussainweb/drupal-composer-helper:~1.0
- 从
scripts
部分的post-install-cmd
和post-update-cmd
中移除'DrupalProject\\composer\\ScriptHandler::createRequiredFiles'
。插件创建所有必要的文件。 - (可选) 在上述更改之后,您可能可以完全删除
scripts/composer/ScriptHandler.php
文件(如果您没有进行任何更改)并从 composer.json 中删除任何引用。在autoload
部分中以及pre-install-cmd
和post-install-cmd
脚本中都有一些引用。此功能不在插件中,但它并不是真正必要的,因为它只是对 composer 的版本检查。 - (可选) 如果您没有更改
composer.json
中extra
部分的installer-paths
部分中的任何路径,则可以删除它们。插件设置了与模板设置的默认值相匹配的默认值。此部分中的路径将优先于插件默认值。
配置
该插件在 composer.json
文件中提供以下配置选项(和默认值)
{
...
"extra": {
"drupal-composer-helper": {
"set-d7-paths": false
},
...
},
...
Drupal 路径
此插件使用新提供的 新 core Drupal 框架插件 提供的设置来查找 Drupal 安装路径。它使用此作为前缀来设置所有与 Drupal 相关的安装路径,以便 Drupal 核心模块和主题可以安装在正确的位置。该插件还在此目录中运行框架并创建其他所需的 Drupal 文件。
示例
{
...
"extra": {
"drupal-scaffold": {
"locations: {
"web-root": "web/"
}
},
"drupal-composer-helper": {
"additional-cleanup": [],
"set-d7-paths": false
},
...
},
...
对于 Drupal 8 设置,此插件设置的默认值如下
'core': 'web/core/',
'module': 'web/modules/contrib/{$name}/',
'theme': 'web/themes/contrib/{$name}/',
'library': 'web/libraries/{$name}/',
'profile': 'web/profiles/contrib/{$name}/',
'drush': 'drush/{$name}/',
'custom-theme': 'web/themes/custom/{$name}/',
'custom-module': 'web/modules/custom/{$name}/',
上述只是默认值,可以通过在您的 composer.json 文件中 extra
部分的 installer-paths
属性中覆盖。
drupal-web-dir (已弃用)
默认值: 'web'
此设置已被弃用,改为使用核心的Drupal框架插件设置设置。如果未设置该值,插件会回退到此设置,但为了与Drupal生态系统其他部分兼容,使用新设置是一个好主意。
web-prefix (已弃用)
默认值: 'web'
此设置已被弃用,改为使用核心的Drupal框架插件设置设置。如果未设置该值,插件会回退到此设置,但为了与Drupal生态系统其他部分兼容,使用新设置是一个好主意。
另请参阅:set-d7-paths
。
additional-cleanup (已移除)
默认值:空数组
这已被drupal/core-vendor-hardening
中的功能所替代。您仍需要在composer.json中显式要求该插件。插件只建议添加它。
set-d7-paths
默认值:false
如果您正在构建基于Drupal 7的网站,请将此设置为true
。此配置选项将默认的installer-paths
路径更改为Drupal 7典型路径。
如果您的web-prefix
是docroot
,如果此选项为true
,则设置的installer-paths
如下。
'core': 'docroot/',
'module': 'docroot/sites/all/modules/contrib/{$name}/',
'theme': 'docroot/sites/all/themes/contrib/{$name}/',
'library': 'docroot/sites/all/libraries/{$name}/',
'profile': 'docroot/sites/all/profiles/contrib/{$name}/',
'drush': 'drush/{$name}/',
'custom-theme': 'docroot/sites/all/themes/custom/{$name}/',
'custom-module': 'docroot/sites/all/modules/custom/{$name}/',
贡献
欢迎贡献。请使用问题队列来描述问题。欢迎提交拉取请求。