Skip to main content

Introduction

Laravel Envoy is a tool for executing common tasks you run on your remote servers. Using Blade style syntax, you can easily set up tasks for deployment, Artisan commands, and more.
Currently, Envoy only supports the Mac and Linux operating systems. However, Windows support is achievable using WSL2.

Installation

First, install Envoy into your project using the Composer package manager:
Once Envoy has been installed, the Envoy binary will be available in your application’s vendor/bin directory:

Writing Tasks

Defining Tasks

Tasks are the basic building block of Envoy. Tasks define the shell commands that should execute on your remote servers when the task is invoked. All of your Envoy tasks should be defined in an Envoy.blade.php file at the root of your application.
As you can see, an array of @servers is defined at the top of the file, allowing you to reference these servers via the on option of your task declarations. The @servers declaration should always be placed on a single line.

Local Tasks

You can force a script to run on your local computer by specifying the server’s IP address as 127.0.0.1:

Importing Envoy Tasks

Using the @import directive, you may import other Envoy files so their stories and tasks are added to yours.

Multiple Servers

Envoy allows you to easily run a task across multiple servers. First, add additional servers to your @servers declaration. Once you have defined your additional servers you may list each of them in the task’s on array:

Parallel Execution

By default, tasks will be executed on each server serially. If you would like to run a task across multiple servers in parallel, add the parallel option to your task declaration:

Setup

Sometimes, you may need to execute arbitrary PHP code before running your Envoy tasks. You may use the @setup directive:
If you need to require other PHP files before your task is executed, use the @include directive at the top of your Envoy.blade.php file:

Variables

If needed, you may pass arguments to Envoy tasks by specifying them on the command line when invoking Envoy:
You may access the options within your tasks using Blade’s “echo” syntax and define if statements and loops:

Stories

Stories group a set of tasks under a single, convenient name.
Once the story has been written, you may invoke it in the same way you would invoke a task:

Hooks

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 your tasks interact with.
The @finished hooks receive the status code of the completed task, which may be null or an integer greater than or equal to 0.

Running Tasks

To run a task or story that is defined in your application’s Envoy.blade.php file, execute Envoy’s run command:

Confirming Task Execution

If you would like to be prompted for confirmation before running a given task on your servers, add the confirm directive to your task declaration. This option is particularly useful for destructive operations:

Notifications

Slack

Envoy supports sending notifications to Slack after each task is executed. The @slack directive accepts a Slack hook URL and a channel / user name.
You may overwrite the default message by passing a third argument to the @slack directive:

Discord

Telegram

Microsoft Teams

The @teams directive accepts a Teams webhook (required), a message, a theme color (success, info, warning, error), and an optional array of options.
Envoy relies on SSH connections to your remote servers. Make sure key-based authentication and server access are configured before running tasks. For more advanced deployment automation, consider combining Envoy with the deployment guide or GitHub Actions.
Last modified on July 20, 2026