无法在 php 中 运行 飞行路线命令

Cannot run flyway commands in php

我正在尝试 运行 来自 php 的函数内的一些飞行路线命令。 这是一个简单干净的函数,如下所示:

function clean_schema() {
    chdir('my/current/path');
    try{
        exec('flyway clean', $output, $result);}
    catch(Exception $e){
        var_dump($e);
    }
}

现在作为输出和结果,我得到一个空数组和错误 127。我环顾四周,发现这意味着我没有将 flyway 设置为系统环境,但是如果我 运行直接在我的 cmd shell 程序中使用 flyway clean 命令,它工作得很好。

Error code 127 means the executable was not found in the given context. Your shell differs from one executed from the web context, probably because your PATH environment variable is different.

您是否尝试过使用 absolute path 执行应用程序?首先了解可执行文件的位置:

which flyway

然后:

exec('/absolute/path/flyway clean', $output, $result);