Envoy – A effective remote server automation and deployment tool for php

Envoy is a remote server automation and deployment tool written in php. It provides you a simple and effective way to run common tasks on your remote servers. So, you needn’t to connect to your remote server with ssh client and then run the task. In this article, i will show you an example about how to use this great tool in your detail development.

Envoy Installation

It is necessary to install envoy via composer. If you didn’t install the composer yet, please read my previous article at http://blog.arvixe.com/tomatocart-use-composer-to-manage-php-dependency-in-tomatocart/.

To install Envoy simply run:

composer global require "laravel/envoy"

Once it is installed, you will find it under ~/.composer/vendor/bin.


Run following command to make envoy executable:

chmod +x ~/.composer/vendor/bin/envoy

In order to run the envoy command without absolute path, you need to ensure it is searchable by shell automatically. Please run following command:

sudo ln -s ~/.composer/vendor/bin/envoy /usr/bin/envoy

Now, when you type envoy in the shell, you will see following help document for it:


Define ssh task

Step 1. Create Envoy.blade.php under root directory of your project.

Step 2. Setup it to declare variables and execute php work before evaluating the ssh tasks.

    $environment = isset($env) ? $env : 'test';

    switch ($environment) {
        case 'test':
            $ssh_server = 'tomatocart-test';
            $basepath = '/var/www/tomatocart';
        case 'live':
            $ssh_server = 'tomatocart-live';
            $basepath = '/var/www/tomatocart.com';
            $ssh_server = 'tomatocart-test';
            $basepath = '/var/www/tomatocart';

As you see, i set the ssh server based on the environment and base path to the project in the host server. The ssh server is just ssh configs defined under ~/.ssh/config:


Step3. Set the server.

@servers(['tomatocart' => $ssh_server]);

Note: you could also set the multiple servers.

Step 4. Define ssh tasks.

@task('server:restart', ['on' => 'tomatocart'])
    sudo service apache2 restart

@task('git:pull', ['on' => 'tomatocart'])
    cd {{ $basepath }}

    sudo git pull -u

@task('asset:compile', ['on' => 'tomatocart'])
    cd {{ $basepath }}

    sudo gulp

As you can see:

  • I define server:restart task to restart the remote server.
  • I define git:pull task to pull the code from repository automatically in the remote server.
  • I define asset:compile task to compile the js, css etc in the remote server.

Step 5. Define a deploy task to execute multiple tasks.

@macro('deploy', ['on' => 'tomatocart'])

Now, just need to go the root directory of project and then execute following command to do deploy the application.

envoy run deploy --env=live

Final Word

This is really useful tool for daily development. Please test it by yourself. You could define any kind of task to be executed automatically in the remote server. It means that you needn’t to login into remote server via ssh to type the command one by one. It’s powerful and effective.

Looking for quality TomatoCart hosting? Check out Arvixe Web Hosting

Tags: , , | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

Leave a Reply

Your email address will not be published. Required fields are marked *