You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Web/Documentation/content/main/5-extra-topics/03-contributing.md
+97-66Lines changed: 97 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,33 +9,35 @@ Welcome aboard! We're excited that you are interested in contributing to the Tem
9
9
10
10
To report an error or a bug, please:
11
11
12
-
* Head over to the [issue page](https://github.com/tempestphp/tempest-framework/issues) to open an issue.
13
-
* Provide as much context about the problem you are running into and the environment you are running Tempest in.
14
-
* Provide the version and, if relevant, the component you are running into issues with.
15
-
* For a shot at getting our "Perfect Storm" label, submit a PR with a failing test!
12
+
- Head over to the [issue page](https://github.com/tempestphp/tempest-framework/issues) to open an issue.
13
+
- Provide as much context about the problem you are running into and the environment you are running Tempest in.
14
+
- Provide the version and, if relevant, the component you are running into issues with.
15
+
- For a shot at getting our "Perfect Storm" label, submit a PR with a failing test!
16
16
17
17
Once the issue has been opened, the Tempest team will:
18
18
19
19
<!-- TODO: Update this section with some links -->
20
-
* Label the issue appropriately.
21
-
* Assign the issue to the appropriate team member.
22
-
* Try and get a response to you as quickly as possible.
20
+
21
+
- Label the issue appropriately.
22
+
- Assign the issue to the appropriate team member.
23
+
- Try and get a response to you as quickly as possible.
23
24
24
25
In the event that an issue is opened, but we get no response within 30 days, the issue will be closed.
25
26
26
27
## Request a feature
27
28
28
29
Tempest is a work in progress. We recognize that some features you might benefit from or expect may be missing. If you do have a feature request, please:
29
30
30
-
* Head over to the [issue page](https://github.com/tempestphp/tempest-framework/issues) to open an issue.
31
-
* Provide as much detail about the feature you are looking for and how it might benefit you and others.
31
+
- Head over to the [issue page](https://github.com/tempestphp/tempest-framework/issues) to open an issue.
32
+
- Provide as much detail about the feature you are looking for and how it might benefit you and others.
32
33
33
34
Once the feature request has been opened, the Tempest team will:
34
35
35
36
<!-- TODO: Update this section with some links -->
36
-
* Label the issue appropriately.
37
-
* Ask any clarifying question to help better understand the use case.
38
-
* If the feature requested is accepted, the Tempest team will assign the `{txt}Uncharted waters` label. A Tempest team member or a member of the community can contribute the code for this.
37
+
38
+
- Label the issue appropriately.
39
+
- Ask any clarifying question to help better understand the use case.
40
+
- If the feature requested is accepted, the Tempest team will assign the `{txt}Uncharted waters` label. A Tempest team member or a member of the community can contribute the code for this.
39
41
40
42
:::tip
41
43
We welcome all contributions and greatly value your time and effort. To ensure your work aligns with Tempest's vision and avoids unnecessary effort, we aim to provide clear guidance and feedback throughout the process.
@@ -50,47 +52,52 @@ We welcome contributions of any size! Feel free to submit a pull request, even i
50
52
:::
51
53
52
54
To contribute to Tempest's documentation, please:
53
-
* Head over to the [Tempest docs repository](https://github.com/tempestphp/tempest-docs) to fork the project.
54
-
* Add or edit any relevant documentation in a manner consistent with the rest of the documentation.
55
-
* Re-read what you wrote and run it through a spell checker.
56
-
* Open a pull request with your changes.
55
+
56
+
- Head over to the [Tempest docs repository](https://github.com/tempestphp/tempest-docs) to fork the project.
57
+
- Add or edit any relevant documentation in a manner consistent with the rest of the documentation.
58
+
- Re-read what you wrote and run it through a spell checker.
59
+
- Open a pull request with your changes.
57
60
58
61
Once a pull request has been opened, the Tempest team will:
59
-
* Use GitHub reviews to review your pull request.
60
-
* If necessary, ask for revisions.
61
-
* If we decide to pass on your pull request, we will thank you for your contribution and explain our decision. We appreciate all the time contributors put into Tempest!
62
-
* If your pull request is accepted, we will mark it as such and merge it into the project. It will be released in the next tagged version! 🎉
62
+
63
+
- Use GitHub reviews to review your pull request.
64
+
- If necessary, ask for revisions.
65
+
- If we decide to pass on your pull request, we will thank you for your contribution and explain our decision. We appreciate all the time contributors put into Tempest!
66
+
- If your pull request is accepted, we will mark it as such and merge it into the project. It will be released in the next tagged version! 🎉
63
67
64
68
## Contribute code
65
69
66
70
So, you want to dive into the code. To make the most of your time, please ensure that any contributions pertain to an approved feature request or a confirmed bug. This helps us focus on the vision for Tempest and ensuring the best developer experience.
67
71
68
72
To contribute to Tempest's code, you will need to first [setup Tempest locally](#setting-up-tempest-locally). Then,
69
-
* Make the relevant code changes.
70
-
* Write tests that verify that your contribution works as expected.
71
-
* Run `composer qa` to ensure you are adhering to our style guidelines.
72
-
* Create a [pull request](https://github.com/tempestphp/tempest-framework/pulls) with your changes.
73
-
* If your pull request is connected to an open issue, add a line in your description that says `{txt}Fixes #xxx`, where `{txt}#xxx` is the number of the issue you're fixing.
73
+
74
+
- Make the relevant code changes.
75
+
- Write tests that verify that your contribution works as expected.
76
+
- Run `composer qa` to ensure you are adhering to our style guidelines.
77
+
- Create a [pull request](https://github.com/tempestphp/tempest-framework/pulls) with your changes.
78
+
- If your pull request is connected to an open issue, add a line in your description that says `{txt}Fixes #xxx`, where `{txt}#xxx` is the number of the issue you're fixing.
74
79
75
80
:::tip Pull request titles
76
81
We use [conventional commits](#commit-and-merge-conventions) to automatically generate readable changelogs. You may help with this by providing a clear pull request title, which will appear in the changelog and needs to be understandable without the pull request's content as a context. Read more about this in the [pull requests](#pull-requests) section.
77
82
:::
78
83
79
84
Once a pull request has been opened, the Tempest team will:
80
-
* Use GitHub reviews to review your pull request.
81
-
* Ensure all CI pipelines are passing.
82
-
* If necessary, ask for revisions.
83
-
* If we decide to pass on your pull request, we will thank you for your contribution and explain our decision. We appreciate all the time contributors put into Tempest!
84
-
* If your pull request is accepted, we will mark it as such and merge it into the project. It will be released in the next tagged version! 🎉
85
+
86
+
- Use GitHub reviews to review your pull request.
87
+
- Ensure all CI pipelines are passing.
88
+
- If necessary, ask for revisions.
89
+
- If we decide to pass on your pull request, we will thank you for your contribution and explain our decision. We appreciate all the time contributors put into Tempest!
90
+
- If your pull request is accepted, we will mark it as such and merge it into the project. It will be released in the next tagged version! 🎉
85
91
86
92
### Setting up Tempest locally
87
93
88
-
* Install PHP.
89
-
* Install Composer.
90
-
* Install [Bun](https://bun.sh) or Node.
91
-
*[Fork and clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) the Tempest repository.
94
+
- Install PHP.
95
+
- Install Composer.
96
+
- Install [Bun](https://bun.sh) or Node.
97
+
-[Fork and clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) the Tempest repository.
92
98
93
99
In your terminal, run:
100
+
94
101
```sh
95
102
cd /path/to/your/clone
96
103
composer update
@@ -108,16 +115,16 @@ Add the following in your `composer.json`, replacing `{txt}/path/to/your/clone`
108
115
109
116
```json
110
117
{
111
-
// ...
112
-
"repositories": [
113
-
{
114
-
"type": "path",
115
-
"url": "/path/to/your/clone"
116
-
}
117
-
],
118
-
"minimum-stability": "dev",
119
-
"prefer-stable": true
120
-
// ...
118
+
// ...
119
+
"repositories": [
120
+
{
121
+
"type": "path",
122
+
"url": "/path/to/your/clone"
123
+
}
124
+
],
125
+
"minimum-stability": "dev",
126
+
"prefer-stable": true
127
+
// ...
121
128
}
122
129
```
123
130
@@ -133,7 +140,7 @@ bun install /Users/you/Code/forks/tempest/packages/vite-plugin-tempest
133
140
134
141
Do not forget to run `bun dev` in the root of your local version of the framework, so your changes can be reflected on your local application without needing to run `bun build` each time.
135
142
136
-
### Styling decisions
143
+
### Code style and conventions
137
144
138
145
Tempest uses a modified version of PSR-12. We automate the entire styling process because we know everyone is used to different standards and workflows. To see some of the rules we enforce, check out our [Mago](https://github.com/tempestphp/tempest-framework/blob/main/mago.toml) and [Rector](https://github.com/tempestphp/tempest-framework/blob/main/rector.php) configurations.
139
146
@@ -143,8 +150,8 @@ The following outlines some other guidelines we have established for Tempest.
143
150
144
151
Whenever possible, classes should be `final` and `readonly`. This practice promotes immutability and prevents inadvertent changes to logic.
145
152
146
-
:::tip
147
-
You may watch this [video](https://www.youtube.com/watch?v=HiD6CwWq5Ds&ab_channel=PHPAnnotated) to understand my thoughts about using `final`.
153
+
:::tip{tabler:bulb}
154
+
You may watch this [video](https://www.youtube.com/watch?v=HiD6CwWq5Ds&ab_channel=PHPAnnotated) to understand {x:brendt_gd}'s thoughts about using `final`.
148
155
:::
149
156
150
157
---
@@ -153,53 +160,77 @@ You may watch this [video](https://www.youtube.com/watch?v=HiD6CwWq5Ds&ab_channe
153
160
154
161
Tempest uses a modified version of the [.NET best practices](https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms229043(v=vs.100)?redirectedfrom=MSDN) for acronym casing. Please see below for our guidelines:
155
162
156
-
__Do capitalize all characters of two to three character acronyms, except the first word of a camel-cased identifier.__
163
+
**Do capitalize all characters of two to three character acronyms, except the first word of a camel-cased identifier.**
157
164
A class named `IPAddress` is an example of a short acronym (IP) used as the first word of a Pascal-cased identifier. A parameter named `ipAddress` is an example of a short acronym (ip) used as the first word of a camel-cased identifier.
158
165
159
-
__Do capitalize only the first character of acronyms with four or more characters, except the first word of a camel-cased identifier.__
166
+
**Do capitalize only the first character of acronyms with four or more characters, except the first word of a camel-cased identifier.**
160
167
A class named `UuidGenerator` is an example of a long acronym (Uuid) used as the first word of a Pascal-cased identifier. A parameter named `uuidGenerator` is an example of a long acronym (uuid) used as the first word of a camel-cased identifier.
161
168
162
-
__Do not capitalize any of the characters of any acronyms, whatever their length, at the beginning of a camel-cased identifier.__
169
+
**Do not capitalize any of the characters of any acronyms, whatever their length, at the beginning of a camel-cased identifier.**
163
170
A class named `Uuid` is an example of a long acronym (Uuid) used as the first word of a camel-cased identifier. A parameter named `dbUsername` is an example of a short acronym (db) used as the first word of a camel-cased identifier.
164
171
165
172
---
166
173
167
-
#### Validation class formatting
174
+
#### Validation classes
168
175
169
-
1.__Error message formatting__:
170
-
-__Avoid ending punctuation__. When writing error messages for validation rules, refrain from including ending punctuation such as periods, exclamation marks, or question marks. This helps in maintaining a uniform style and prevents inconsistency in error message presentation.
176
+
When writing error messages for validation rules, **refrain from including ending punctuation** such as periods, exclamation marks, or question marks. This helps in maintaining a uniform style and prevents inconsistency in error message presentation.
171
177
172
178
```diff
173
179
- Value should be a valid email address!
174
180
+ Value should be a valid email address
175
181
```
176
182
183
+
---
184
+
185
+
#### Exception classes
186
+
187
+
Exception classes can be thought of as events and should be named accordingly. Use a subject-verb structure in the past tense to describe what happened (e.g., `DatabaseOperationFailed`, `StorageUsageWasForbidden`, `AuthenticatedUserWasMissing`).
188
+
189
+
- Do not suffix class names with `Exception`; the context of `throw` or `catch` language constructs makes their purpose clear.
190
+
- All exception classes must extend PHP's built-in `\Exception`.
191
+
- When appropriate, define marker interfaces such as `CacheException`, `DatabaseException`, or `FilesystemException` to group related exceptions. These interfaces must be suffixed with `Exception`.
192
+
- Set the exception message within the exception class itself—not where it is thrown.
193
+
- Override the constructor to only accept relevant context-specific input.
194
+
195
+
For instance, the following exception accepts a the relevant cache key as a constructor argument, and keeps it accessible through a public property:
196
+
197
+
```php LockAcquisitionTimedOut.php
198
+
final class LockAcquisitionTimedOut extends Exception implements CacheException
199
+
{
200
+
public function __construct(
201
+
public readonly string $key,
202
+
) {
203
+
parent::__construct("Lock with key `{$key}` could not be acquired on time.");
204
+
}
205
+
}
206
+
```
207
+
177
208
## Release workflow
178
209
179
210
Tempest uses sub-splits to allow components to be installed as individual packages. The following outlines how this process works.
180
211
181
212
### Workflow steps
182
213
183
214
1.**Trigger event**
184
-
- When a pull request is merged, or a new tag is created, the `.github/workflows/subsplit-packages.yml` action is run.
215
+
- When a pull request is merged, or a new tag is created, the `.github/workflows/subsplit-packages.yml` action is run.
185
216
186
217
2.**Package information retrieval**
187
-
- When the `subsplit-packages.yml` is run, it calls `bin/get-packages`.
188
-
- This PHP script uses a combination of Composer and the filesystem to return (in JSON) some information about every package. It returns the:
189
-
-**Directory**
190
-
-**Name**
191
-
-**Package**
192
-
-**Organization**
193
-
-**Repository**
218
+
- When the `subsplit-packages.yml` is run, it calls `bin/get-packages`.
219
+
- This PHP script uses a combination of Composer and the filesystem to return (in JSON) some information about every package. It returns the:
220
+
-**Directory**
221
+
-**Name**
222
+
-**Package**
223
+
-**Organization**
224
+
-**Repository**
194
225
195
226
3.**Action matrix creation**
196
-
- The result of the `get-packages` command is then used to create an action matrix.
197
-
- This ensures that the next steps are performed for _every_ package discovered.
227
+
- The result of the `get-packages` command is then used to create an action matrix.
228
+
- This ensures that the next steps are performed for _every_ package discovered.
198
229
199
230
4.**Monorepo split action**
200
-
- The `symplify/[email protected]` GitHub action is called for every package and provided the necessary information (destination repo, directory, etc.).
201
-
- This action takes any changes and pushes them to the sub-split repository determined by combining the "Organization" and "Repository" values returned in step 2.
202
-
- Depending on whether a tag is found or not, a tag is also supplied so the repository is tagged appropriately.
231
+
- The `symplify/[email protected]` GitHub action is called for every package and provided the necessary information (destination repo, directory, etc.).
232
+
- This action takes any changes and pushes them to the sub-split repository determined by combining the "Organization" and "Repository" values returned in step 2.
233
+
- Depending on whether a tag is found or not, a tag is also supplied so the repository is tagged appropriately.
0 commit comments