大卫·巴雷特 / drupal-structure
通过 Composer 给 Drupal 6 & 7 添加与 Drupal 8 相似的目录结构
1.0.0-alpha1
2014-09-27 16:44 UTC
Requires
- symfony/filesystem: ~2.0
- symfony/finder: ~2.0
Requires (Dev)
- composer/composer: 1.0.*@alpha
This package is auto-updated.
Last update: 2024-09-12 00:50:30 UTC
README
通过 Composer 给 Drupal 6 & 7 添加与 Drupal 8 相似的目录结构
当运行 Composer 的 install
和 update
时,此脚本执行以下任务
- 在
root
目录下创建libraries
、modules
、themes
和sites
文件夹 - 将
core/sites/README.txt
和core/sites/example.sites.php
复制到sites
- 将
core/sites/default/default.settings.php
复制到sites/default/default.settings.php
- 删除
core/sites
中存在于sites
中的每个文件夹 - 从
core/sites
为每个站点创建符号链接到sites
- 将
core/sites/all/modules/README.txt
复制到modules/README.txt
- 将
core/sites/all/themes/README.txt
复制到themes/README.txt
- 从
core/sites/all/modules
创建符号链接到modules
- 从
core/sites/all/themes
创建符号链接到themes
- 从
core/sites/all/libraries
创建符号链接到libraries
- 如果文件不存在,创建
sites/sites.php
- 从
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 install
或 composer 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