Skip to content

Commit 9b744ef

Browse files
Document new before hook (laravel#7662)
1 parent 4363282 commit 9b744ef

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

envoy.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- [Setup](#setup)
99
- [Variables](#variables)
1010
- [Stories](#stories)
11-
- [Completion Hooks](#completion-hooks)
11+
- [Hooks](#completion-hooks)
1212
- [Running Tasks](#running-tasks)
1313
- [Confirming Task Execution](#confirming-task-execution)
1414
- [Notifications](#notifications)
@@ -175,12 +175,25 @@ Once the story has been written, you may invoke it in the same way you would inv
175175
php vendor/bin/envoy run deploy
176176
177177
<a name="completion-hooks"></a>
178-
### Completion Hooks
178+
### Hooks
179179
180-
When tasks and stories finish, a number of hooks are executed. The hook types supported by Envoy are `@after`, `@error`, `@success`, and `@finished`. All of the code in these hooks is interpreted as PHP and executed locally, not on the remote servers that your tasks interact with.
180+
When tasks and stories run, a number of hooks are executed. The hook types supported by Envoy are `@before`, `@after`, `@error`, `@success`, and `@finished`. All of the code in these hooks is interpreted as PHP and executed locally, not on the remote servers that your tasks interact with.
181181
182182
You may define as many of each of these hooks as you like. They will be executed in the order that they appear in your Envoy script.
183183
184+
<a name="hook-before"></a>
185+
#### `@before`
186+
187+
Before each task execution, all of the `@before` hooks registered in your Envoy script will execute. The `@before` hooks receive the name of the task that will be executed:
188+
189+
```php
190+
@before
191+
if ($task === 'deploy') {
192+
// ...
193+
}
194+
@endbefore
195+
```
196+
184197
<a name="completion-after"></a>
185198
#### `@after`
186199

0 commit comments

Comments
 (0)