Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cpass78's avatar

Calling envoy from a controller

Hi all,

I'm looking to create an application in lara 5 that integrate envoy. Basically a fronted to envoy. Does anyone have any tips or ideas on how to implement something this?

Thanks

0 likes
5 replies
awietz's avatar
awietz
Best Answer
Level 3

You can do like this:

<?php

namespace App\Http\Controllers;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class Controller
{
    protected function index()
    {
        $command = "~/.composer/vendor/bin/envoy run deploy --some=param";
        $directory = base_path();

        $process = new Process($command);
        $process->setTimeout(3600);
        $process->setIdleTimeout(300);
        $process->setWorkingDirectory($directory);

        try {
            $process->mustRun();
            print $process->getOutput();
        } catch (ProcessFailedException $e) {
            print $e->getMessage();
        }
    }
}

More help to be found here: https://github.com/symfony/Process http://symfony.com/doc/current/components/process.html

2 likes
christopher's avatar

I am running Laravel with Valet and if i try your example i am getting the following Error Message

The command "~/.composer/vendor/bin/envoy run vpn" failed. Exit Code: 1(General error) Working directory: /Users/user/Desktop/code/deployer Output: ================ Valet requires Brew to be installed on your Mac. Error Output: ================

Brew of course is already installed. Is there any Solution?

1 like

Please or to participate in this conversation.