Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gitwithravish's avatar

Symfony Process: command not found

I am using Symfony Process component.

I have installed this.

resolution command works just fine in my terminal. However I am not able to use it with Process()

CODE

$process = new Process('resolution');
$process->run();

OUTPUT

The command "resolution" failed.
Exit Code: 127(Command not found)

I tried to echo the$PATH variable.

CODE

$process = new Process('echo $PATH');

OUTPUT

/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

The resolution command is stored in /usr/local/bin , so it should work i believe.

All the solutions on the internet points towards checking the $PATH which does not seem like an issue.

Even if I write entire path of the command, it wont work with Process component. It works in normal terminal just fine

CODE

$process = new Process('/usr/local/bin/resolution');
$process->run();

OUTPUT

The command "resolution" failed.
Exit Code: 127(Command not found)

I have tested my code with different laravel versions as well (5.4 and 8). Facing the same issue

0 likes
9 replies
Nakov's avatar

And trying to run any other util that is part of your /usr/local/bin? Or running this resolution from your terminal?

btw, the problem might be not enough permissions as well, the user on your application server might be different than the default from your terminal.

gitwithravish's avatar

Hey, thanks for reply @nakov

the user on your application server might be different than the default from your terminal

I executed whoami from Process() and terminal. Both returns same username only.

And trying to run any other util that is part of your /usr/local/bin?

I ran two commands from /usr/local/bin

Process(['npm','v']); //command not found
Process(['httpd','v']); // worked

How do I debug this, I don't understand.

One of my friend @sinnbeck tested the same thing on linux i guess, it worked just fine. Could it be an OS issue?

gitwithravish's avatar

@nakov basically want to execute shell command from php.

It worked just fine using shell_exec, but the user input is expected to have any valid UTF-8 character, so its not possible to sanitise the input i guess.

So my best chance is to use something like Process.

I would appreciate if you can suggest any alternatives as well.

Thanks

Nakov's avatar

So does running that command from the terminal works? Without the Process class, without Laravel..

gitwithravish's avatar

Tried but no luck.

It returns the appropriate paths.

[edit]

Error Output:
================
env: node: No such file or directory
Kazuto's avatar

@alexmanase Unfortunately this does not work.

$command = [
    (new ExecutableFinder())->find('yarn', 'yarn', [
        '/usr/local/bin',
        '/opt/homebrew/bin',
    ]),
    'build',
];

// [
//   "/opt/homebrew/bin/yarn",
//   "build"
// ]

$process = Process::path(app()->basePath())->command($command);

$result = $process->run();

dump(
  $result->output(), // ""
  $result->errorOutput() // "env: node: No such file or directory"
);

Running /opt/homebrew/bin/yarn build in the terminal works though.

1 like

Please or to participate in this conversation.