29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Envoy Task Runner 341<br />

Writing Tasks<br />

All of your Envoy tasks should be defined in an Envoy.blade.php file in the root of your project.<br />

Here’s an example to get you started:<br />

.<br />

1 @servers(['web' => 'user@192.168.1.1'])<br />

2<br />

3 @task('foo', ['on' => 'web'])<br />

4 ls -la<br />

5 @endtask<br />

As you can see, an array of @servers is defined at the top of the file, allowing you to reference these<br />

servers in the on option of your task declarations. Within your @task declarations, you should place<br />

the Bash code that will be run on your server when the task is executed.<br />

Bootstrapping<br />

Sometimes, you may need to execute some PHP code before evaluating your Envoy tasks. You may<br />

use the @setup directive to declare variables and do general PHP work inside the Envoy file:<br />

.<br />

1 @setup<br />

2 $now = new DateTime();<br />

3<br />

4 $environment = isset($env) ? $env : "testing";<br />

5 @endsetup<br />

You may also use @include to include any outside PHP files:<br />

.<br />

1 @include('vendor/autoload.php');<br />

Confirming Tasks<br />

If you would like to be prompted for confirmation before running a given task on your servers, you<br />

may add the confirm directive to your task declaration:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!