Calling symfony/process inside Laravel controller always returns "<command> is not recognized"

I was trying to git pull by calling a spesific route.
I’m using symfony/process inside my controller like so:

public function pull()
{
    $process = new Process(["git","pull"]);
    $process->setWorkingDirectory(base_path());
    $process->run(function ($type, $buffer) {
        if (Process::ERR === $type) {
            echo 'ERR > '.$buffer;
        } else {
            echo 'OUT > '.$buffer;
        }
    });
}

when I hit the route it returns:

ERR > 'git' is not recognized as an internal or external command, operable program or batch file.

then I tried to change the command to any other command like ls, npm install, rm, etc… and it is still returning the same error.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *