Reading .env from Laravel Envoy

Recently, a bit late to the game, I discovered Envoy, Laravel’s official task runner. Using Blade style syntax, you can efficiently setup tasks for deployment, Artisan commands, and more.

However, one thing I noticed is that Envoy does not read .env-configuration files. But this is easily fixed by using the Dotenv library and the @setup-directive directly.

@setup 

require __DIR__.'/vendor/autoload.php'; 
(new \Dotenv\Dotenv(__DIR__, '.env'))->load();

$server = env('SERVER_IP')

@endsetup

Now you no longer have to commit IP-addresses into your repository.