大卫·巴雷特/drupal-structure

通过 Composer 给 Drupal 6 & 7 添加与 Drupal 8 相似的目录结构

1.0.0-alpha1 2014-09-27 16:44 UTC

This package is auto-updated.

Last update: 2024-09-12 00:50:30 UTC


README

通过 Composer 给 Drupal 6 & 7 添加与 Drupal 8 相似的目录结构

当运行 Composer 的 installupdate 时,此脚本执行以下任务

  1. root 目录下创建 librariesmodulesthemessites 文件夹
  2. core/sites/README.txtcore/sites/example.sites.php 复制到 sites
  3. core/sites/default/default.settings.php 复制到 sites/default/default.settings.php
  4. 删除 core/sites 中存在于 sites 中的每个文件夹
  5. core/sites 为每个站点创建符号链接到 sites
  6. core/sites/all/modules/README.txt 复制到 modules/README.txt
  7. core/sites/all/themes/README.txt 复制到 themes/README.txt
  8. core/sites/all/modules 创建符号链接到 modules
  9. core/sites/all/themes 创建符号链接到 themes
  10. core/sites/all/libraries 创建符号链接到 libraries
  11. 如果文件不存在,创建 sites/sites.php
  12. core/sites/sites.php 创建符号链接到 sites/sites.php

安装

在您的 composer.json 文件中需要此库

{
  "require": {
    "davidbarratt/drupal-structure": "1.0.*@alpha",
  }
}

添加脚本

{
  "scripts": {
    "post-install-cmd": [
      "DavidBarratt\\DrupalStructure\\ScriptHandler::postUpdate"
    ],
    "post-update-cmd": [
      "DavidBarratt\\DrupalStructure\\ScriptHandler::postUpdate"
    ]
  }
}

配置

默认情况下,该脚本假定 Drupal 核心位于 core 目录,资源(模块、主题等)位于与您的 composer.json 文件相同的目录。

但是,如果您想自定义它,只需在 extra 中添加参数即可。以下是默认值(不需要添加)

{
  "extra": {
      "drupal-structure": {
        "root": "",
        "core": "core"
      }
  }
}

用法

您可以通过执行 composer installcomposer update 来使用此脚本。Composer 会在过程完成后执行脚本。

示例

以下是一个更实际的示例,说明您如何在真实的 composer.json 文件中使用此脚本。此设置假定网站根目录为 core。但是,您可以复制 index.php.htaccess 并根据需要修改它们。

{
  "repositories": [
    {
      "type": "composer",
      "url": "http://static.drupal-packagist.org/v0.2.0/"
    }
  ],
  "require": {
    "mnsami/composer-custom-directory-installer": "1.0.*",
    "drupal/drupal": "~7.0",
    "davidbarratt/drupal-structure": "1.0.*@alpha"
  },
  "extra": {
      "installer-paths":{
        "core/": ["drupal/drupal"]
      }
  },
  "scripts": {
    "post-install-cmd": [
      "DavidBarratt\\DrupalStructure\\ScriptHandler::postUpdate"
    ],
    "post-update-cmd": [
      "DavidBarratt\\DrupalStructure\\ScriptHandler::postUpdate"
    ]
  }
}

更复杂的示例请见: https://github.com/davidbarratt/drupal7/blob/master/composer.json