1

I'm trying to use envoy from laravel to call some scripts on my server. Right now I'm doing it with a virtual machine installed on my mac.

I'm trying to run my envoy scripts from a controller as follow:

function __construct()
{
    $command = "/Users/test_user/.composer/vendor/bin/envoy run test --filename=new_folder"

    $process = new Process($command);
    $process->start();

    foreach ($process as $type => $data) {
        if ($process::OUT === $type) {
            echo "\nRead from stdout: ".$data;
        } else { // $process::ERR === $type
            echo "\nRead from stderr: ".$data;
        }
    }
    exit();
}

Now when let this run I get the following response:

Read from stdout: Valet requires Homebrew to be installed on your Mac.

If I open my terminal and run: which brew

which brew
/usr/local/bin/brew

and my $PATH

/Users/test_user/Android/platform-tools:/Users/test_user/Android/tools:~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin alias numFiles='echo 14'

I'm not exactly sure why this seems to fail?

Valet was installed with the composer global require laravel/valet command, and was not installed locally for the project.

Is there any way of fixing this?

bfontaine
  • 18,169
  • 13
  • 73
  • 107
killstreet
  • 1,251
  • 2
  • 15
  • 37

1 Answers1

0

You should install envoy locally in your project:

composer require laravel/envoy

and execute it from vendor/bin/envoy.

Also don't forget to set the working directory for the process to base path, assuming your Envoy.blade.php is in the root path of your app.

function __construct()
{
  $command = base_path('vendor/bin') . "/envoy run test --filename=new_folder"

  $process = new Process($command);
  $process->setWorkingDirectory(base_path());
  $process->start();

  foreach ($process as $type => $data) {
    if ($process::OUT === $type) {
        echo "\nRead from stdout: ".$data;
    } else { // $process::ERR === $type
        echo "\nRead from stderr: ".$data;
    }
  }
  exit();
}
Can Celik
  • 2,050
  • 21
  • 30