Skip to content

Commit 2e52eaa

Browse files
committed
feat(doc): Add composer section
1 parent 6cb2a7b commit 2e52eaa

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: "Composer"
3+
linkTitle: "Composer"
4+
weight: 15
5+
type: "landing"
6+
draft: false
7+
translated: false
8+
resources:
9+
- src: "**.{png,jpg}"
10+
title: "Image #:counter"
11+
params:
12+
byline: "Image: Drupal / CC-BY-CA"
13+
categories:
14+
- wxt
15+
tags:
16+
- composer
17+
---
18+
19+
{{% alert color="warning" %}}
20+
A reminder that **[composer](https://getcomposer.org/download/)** is required for the installation and updating of **[Drupal WxT](https://github.com/drupalwxt/wxt)**.
21+
{{% /alert %}}
22+
23+
We highly recommend using our **[Composer Project Template][wxt-project]** to build and maintain your WxT derived project’s codebase.
24+
25+
## Getting Started
26+
27+
The following command is all you need to get started:
28+
29+
```sh
30+
composer create-project drupalwxt/wxt-project:4.2.0 <site-name>
31+
```
32+
33+
> **Note**: For development you may also specify a branch using `drupalwxt/wxt-project:4.2.x-dev`.
34+
35+
You can see a working example of a fully generated Composer Project Template over at:
36+
37+
- **[Site WxT][site-wxt]**
38+
39+
Where the following is the command that was used for the initial generation:
40+
41+
```sh
42+
composer create-project drupalwxt/wxt-project:4.2.0 site-wxt
43+
```
44+
45+
> **Note**: Remember to keep the `composer.json` and `composer.lock` files that exist above `docroot` in source control as they are controlling your dependencies.
46+
47+
## Maintenance
48+
49+
List of common commands are as follows:
50+
51+
| Task | Composer |
52+
| ----------------------------------------------- | --------------------------------------------- |
53+
| Installing a contrib project (latest version) | `composer require drupal/PROJECT` |
54+
| Installing a contrib project (specific version) | `composer require drupal/PROJECT:1.0.0-beta5` |
55+
| Updating all projects including Drupal Core | `composer update` |
56+
| Updating a single contrib project | `composer update drupal/PROJECT_NAME` |
57+
| Updating Drupal Core | `composer update drupal/core` |
58+
59+
> **Note**: Composer is a **dependency manager** and helps us keep track of what code and at what version our application relies on so that it always get installed the right way on every copy of that application.
60+
61+
### Specifying a version
62+
63+
A specific version can be specified from the cli:
64+
65+
```sh
66+
composer require drupal/<modulename>:<version>
67+
```
68+
69+
However please note if you specify a branch, such as 1.x you must add `-dev` to the end of the version:
70+
71+
```sh
72+
composer require drupal/token:1.x-dev
73+
```
74+
75+
### Source Control
76+
77+
Taking a look at the `.gitignore` file, you will discover that certain directories, including all those directories containing contributed projects, are excluded from source control which is by design.
78+
79+
> **Note**: Unlike **[Drush][drush]** in a Composer derived project you should **never commit your install dependencies to source control**.
80+
81+
Composer will create `composer.lock` file, which is a list of dependencies that were installed, and in which versions.
82+
83+
> **Note**: In general you should always **commit your `composer.lock` file to source control** so that others via a quick `composer install` can have everything installed along with the correct versions specified in the `composer.lock` file.
84+
85+
### How to update Drupal Core?
86+
87+
Please **don't add `drupal/core` to your project's composer.json** since WxT manages Drupal Core for you along with the series of patches on top of it.
88+
89+
WxT's minor versions will always correspond to Drupal Core's. For example, `drupalwxt/wxt:~4.2.0` will require Drupal Core 9.2.x and `drupalwxt/wxt:~4.1.0` will require Drupal Core 9.1.x.
90+
91+
When you need to update Drupal Core as an example from 9.1.x to 9.2.x, all you would do is change your requirement for `drupalwxt/wxt` in your `composer.json` file:
92+
93+
```
94+
composer require --no-update drupalwxt/wxt:~4.2.0
95+
composer update
96+
```
97+
98+
### Compatibility table
99+
100+
| `drupalwxt/wxt` version | Drupal Core version | Drush version |
101+
| ----------------------- | ------------------- | ------------- |
102+
| `~4.2.0` | 9.2.x | `>=9.7` |
103+
| `~4.1.0` | 9.1.x | `>=9.7` |
104+
| `~4.0.0` | 8.8.x+ | `>=9.7` |
105+
106+
<!-- Links Referenced -->
107+
108+
[acquia]: https://acquia.com
109+
[blt]: https://github.com/acquia/blt
110+
[composer]: https://getcomposer.org
111+
[docker-scaffold]: https://github.com/drupalwxt/docker-scaffold.git
112+
[drush]: https://www.drush.org/latest/
113+
[githubci]: https://github.com/drupalwxt/site-wxt/actions
114+
[githubci-badge]: https://github.com/drupalwxt/site-wxt/workflows/build/badge.svg
115+
[lightning]: https://github.com/acquia/lightning
116+
[node]: https://nodejs.org
117+
[site-wxt]: https://github.com/drupalwxt/site-wxt
118+
[readme]: https://github.com/drupalwxt/wxt/blob/4.2.x/README.md
119+
[wxt]: https://github.com/drupalwxt/wxt
120+
[wxt-project]: https://github.com/drupalwxt/wxt-project

0 commit comments

Comments
 (0)