0

I wrote an Envoy task which I was running from the terminal. Now I made a view in my App to run it by pressing a button. The problem is that before envoy was being ran by my user but now its being run with the nginx user which hasn't Envoy installed from Composer and I'm getting this error:

sh: 1: /home/vagrant/.config/composer/vendor/bin/envoy: not found

How can I solve this?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Alan
  • 2,559
  • 4
  • 32
  • 53
  • The way around this is to run PHP as the user you want to run envoy.. – Devon Bessemer Sep 05 '16 at 15:33
  • And then I should replicate the user with the packages installed in all the development environments? not a good solution – Alan Sep 05 '16 at 15:35
  • I don't know what you expect. When you run envoy manually, you are running it as your user. You clearly have nginx configured to serve PHP under the user nginx. They are going to have different environments and permissions. – Devon Bessemer Sep 05 '16 at 15:37

1 Answers1

1

If you run composer require laravel/envoy without using the global tag you'll find envoy installed in the vendor folder where the web server can access it.

To run a task use the path to envoy in the vendor folder. For example,

$command = base_path().'/vendor/bin/envoy run mytask';

You can run this via a process, something like $process = new Process($command); The process will be ran as whatever user the web server is using, in your case nginx.

Dave Carruthers
  • 542
  • 1
  • 8
  • 29