# Drupal Composer Scaffold
This project provides a composer plugin for placing scaffold files (like
`index.php`, `update.php`, …) from the `drupal/core` project into their desired
location inside the web root. Only individual files may be scaffolded with this
plugin.
The purpose of scaffolding files is to allow Drupal sites to be fully managed by
Composer, and still allow individual asset files to be placed in arbitrary
locations. The goal of doing this is to enable a properly configured composer
template to produce a file layout that exactly matches the file layout of a
Drupal 8.7.x and earlier tarball distribution. Other file layouts will also be
possible; for example, a project layout very similar to the current
[drupal-composer/drupal-project](https://github.com/drupal-composer/drupal-scaffold)
template will also be provided. When one of these projects is used, the user
should be able to use `composer require` and `composer update` on a Drupal site
immediately after untarring the downloaded archive.
Note that the dependencies of a Drupal site are only able to scaffold files if
explicitly granted that right in the top-level composer.json file. See
[allowed packages](#allowed-packages), below.
## Usage
Drupal Composer Scaffold is used by requiring `drupal/core-composer-scaffold` in your
project, and providing configuration settings in the `extra` section of your
project's composer.json file. Additional configuration from the composer.json
file of your project's dependencies is also consulted in order to scaffold the
files a project needs. Additional information may be added to the beginning or
end of scaffold files, as is commonly done to `.htaccess` and `robots.txt`
files. See [altering scaffold files](#altering-scaffold-files) for more
information.
Typically, the scaffold operations run automatically as needed, e.g. after
`composer install`, so it is usually not necessary to do anything different
to scaffold a project once the configuration is set up in the project
composer.json file, as described below. To scaffold files directly, run:
```
composer drupal:scaffold
```
### Allowed Packages
Scaffold files are stored inside of projects that are required from the main
project's composer.json file as usual. The scaffolding operation happens after
`composer install`, and involves copying or symlinking the desired assets to
their destination location. In order to prevent arbitrary dependencies from
copying files via the scaffold mechanism, only those projects that are
specifically permitted by the top-level project will be used to scaffold files.
Example: Permit scaffolding from the project `drupal/core`
```
"name": "my/project",
...
"extra": {
"drupal-scaffold": {
"allowed-packages": [
"drupal/core"
],
...
}
}
```
Allowing a package to scaffold files also permits it to delegate permission to
scaffold to any project that it requires itself. This allows a package to
organize its scaffold assets as it sees fit. For example, the project
`drupal/core` may choose to store its assets in a subproject `drupal/assets`.
It is possible for a project to obtain scaffold files from multiple projects.
For example, a Drupal project using a distribution, and installing on a specific
web hosting service provider might take its scaffold files from:
- Drupal core
- Its distribution
- A project provided by the hosting provider
- The project itself
Each project allowed to scaffold by the top-level project will be used in turn,
with projects declared later in the `allowed-packages` list taking precedence
over the projects named before. `drupal/core` is implicitly allowed and will be
placed at the top of the list. The top-level composer.json itself is also
implicitly allowed to scaffold files, and its scaffold files have highest
priority.
### Defining Project Locations
The top-level project in turn must define where the web root is located. It does
so via the `locations` mapping, as shown below:
```
"name": "my/project",
...
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "./docroot"
},
...
}
}
```
This makes it possible to configure a project with different file layouts; for
example, either the `drupal/drupal` file layout or the
`drupal-composer/drupal-project` file layout could be used to set up a project.
If a web-root is not explicitly defined, then it will default to `./`.
### Altering Scaffold Files
Sometimes, a project might wish to use a scaffold file provided by a dependency,
but alter it in some way. Two forms of alteration are supported: appending and
patching.
The example below shows a project that appends additional entries onto the end
of the `robots.txt` file provided by `drupal/core`:
```
"name": "my/project",
...
"extra": {
"drupal-scaffold": {
"file-mapping": {
"[web-root]/robots.txt": {
"append": "assets/my-robots-additions.txt",
}
}
}
}
```
It is also possible to prepend to a scaffold file instead of, or in addition to
appending by including a "prepend" entry that provides the relative path to the
file to prepend to the scaffold file.
The example below demonstrates the use of the `post-drupal-scaffold-cmd` hook
to patch the `.htaccess` file using a patch.
```
"name": "my/project",
...
"scripts": {
"post-drupal-scaffold-cmd": [
"cd docroot && patch -p1 <../patches/htaccess-ssl.patch"
]
}
```
### Defining Scaffold Files
The placement of scaffold assets is under the control of the project that
provides them, but the location is always relative to some directory defined by
the root project -- usually the web root. For example, the scaffold file
`robots.txt` is copied from its source location, `assets/robots.txt` into the
web root in the snippet below.
```
{
"name": "drupal/assets",
...
"extra": {
"drupal-scaffold": {
"file-mapping": {
"[web-root]/robots.txt": "assets/robots.txt",
...
}
}
}
}
```
### Excluding Scaffold Files
Sometimes, a project might prefer to entirely replace a scaffold file provided
by a dependency, and receive no further updates for it. This can be done by
setting the value for the scaffold file to exclude to `false`:
```
"name": "my/project",
...
"extra": {
"drupal-scaffold": {
"file-mapping": {
"[web-root]/robots.txt": false
}
}
}
```
If possible, use the `append` and `prepend` directives as explained in [altering
scaffold files](#altering-scaffold-files), above. Excluding a file means that
your project will not get any bug fixes or other updates to files that are
modified locally.
### Overwrite
By default, scaffold files overwrite whatever content exists at the target
location. Sometimes a project may wish to provide the initial contents for a
file that will not be changed in subsequent updates. This can be done by setting
the `overwrite` flag to `false`, as shown in the example below:
```
{
"name": "service-provider/d8-scaffold-files",
"extra": {
"drupal-scaffold": {
"file-mapping": {
"[web-root]/sites/default/settings.php": {
"mode": "replace",
"path": "assets/sites/default/settings.php",
"overwrite": false
}
}
}
}
}
```
Note that the `overwrite` directive is intended to be used by starter kits,
service providers, and so on. Individual Drupal sites should exclude the file
by setting its value to false instead.
### Autoload File
The scaffold tool automatically creates the required `autoload.php` file at the
Drupal root as part of the scaffolding operation. This file should not be
modified or customized in any way. If it is committed to the repository, though,
then the scaffold tool will stop managing it. If the location of the `vendor`
directory is changed for any reason, and the `autoload.php` file has been
committed to the repository, manually delete it and then run `composer install`
to
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP的内容管理系统Drupal源码.zip
共2000个文件
css:919个
js:726个
txt:177个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 91 浏览量
2023-10-15
23:58:46
上传
评论
收藏 25.47MB ZIP 举报
温馨提示
基于PHP的内容管理系统Drupal源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的内容管理系统Drupal源码.zip (2000个子文件)
comment_hacks.css 61KB
editor_ie8.css 37KB
editor_iequirks.css 37KB
editor_ie.css 36KB
action-link.css 36KB
editor_gecko.css 35KB
editor.css 35KB
toolbar.icons.theme.css 26KB
media-library.css 24KB
media-library.pcss.css 23KB
views_ui.admin.theme.css 20KB
views_ui.admin.theme.css 20KB
details.pcss.css 18KB
theme.css 18KB
media-library.css 17KB
details.css 17KB
views_ui.admin.theme.pcss.css 16KB
views_ui.admin.theme.css 16KB
views-ui.pcss.css 15KB
theme.css 15KB
dialog_ie8.css 15KB
theme.pcss.css 15KB
views-ui.css 15KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
form-text.css 14KB
theme.css 14KB
dialog.css 13KB
action-link.pcss.css 13KB
dropbutton.pcss.css 13KB
layout-content-narrow.css 12KB
layout-views-grid-horizontal.css 12KB
autocomplete-loading.module.css 12KB
dropbutton.component.css 11KB
vertical-tabs.pcss.css 10KB
variables.pcss.css 10KB
cke-dialog.css 10KB
header-search-wide.css 10KB
autocomplete-loading.module.pcss.css 10KB
dropbutton.css 10KB
off-canvas.reset.css 10KB
off-canvas.reset.css 10KB
toolbar.icons.theme.pcss.css 9KB
toolbar.icons.theme.css 9KB
toolbar.icons.theme.css 9KB
tabledrag.css 9KB
nav-primary-wide.css 9KB
ckeditor.admin.css 8KB
ckeditor.admin.css 8KB
system.admin.css 8KB
tabs.css 8KB
system.admin.css 8KB
vertical-tabs.css 8KB
form-select.css 8KB
ckeditor-dialog.css 8KB
toolbar.module.css 8KB
tabledrag.pcss.css 8KB
normalize.css 8KB
toolbar.module.pcss.css 8KB
system-status-report-general-info.css 8KB
form.css 8KB
comments.css 8KB
toolbar.module.css 7KB
toolbar.module.css 7KB
ckeditor-dialog.css 7KB
ckeditor-dialog.pcss.css 7KB
tabs.pcss.css 7KB
off-canvas.dropbutton.css 7KB
off-canvas.dropbutton.css 7KB
header-search-narrow.css 7KB
views-ui.css 7KB
form.css 7KB
form--managed-file.pcss.css 7KB
form.css 7KB
form--managed-file.css 7KB
nav-primary.css 7KB
header-search-wide.pcss.css 6KB
workspaces.toolbar.css 6KB
form-select.pcss.css 6KB
form.pcss.css 6KB
fieldset.css 6KB
content-moderation.css 6KB
normalize.css 6KB
variables.pcss.css 6KB
layout-views-grid-horizontal.pcss.css 6KB
form--checkbox-radio.css 6KB
form--checkbox-radio--ie.css 6KB
form-text.pcss.css 6KB
text-content.css 6KB
quickedit.theme.css 6KB
quickedit.theme.css 6KB
embedded-media.css 6KB
details.css 6KB
base.css 5KB
tabs.css 5KB
nav-primary-no-js.css 5KB
primary-menu.css 5KB
form--checkbox-radio.pcss.css 5KB
buttons.css 5KB
layout-builder.css 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
易小侠
- 粉丝: 6475
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功