我正在尝试使用laravel的envoy在我的服务器上调用一些脚本。 现在我正在用我的mac上安装的虚拟机来做这件事。
我正在尝试从控制器运行我的特使脚本,如下所示:
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();
}
现在,当我开始运行时,我得到以下回复:
Read from stdout: Valet requires Homebrew to be installed on your Mac.
如果我打开终端并运行:brew
which brew
/usr/local/bin/brew
和我的$ 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'
我不确定为什么这似乎失败了?
Valet使用composer global require laravel/valet
命令安装,并未在本地安装该项目。
有没有办法解决这个问题?
答案 0 :(得分:0)
您应该在项目中本地安装envoy:
composer require laravel/envoy
并从vendor / bin / envoy执行它。
假设您的Envoy.blade.php
位于应用的根路径中,请不要忘记将流程的工作目录设置为基本路径。
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();
}