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

niseku's avatar

How to run multiple commands with Symfony\Component\Process\Process

Hi

We use a https://www.cloudfoundry.org/ hosting for our app. To connect to the server we have to use cf ssh APP-NAME instead of the normal ssh command.

Now i want to write a simple Task runner like https://deployer.org/ to run some artisan commands on the server. For that i tired Symfony\Component\Process\Process, wich works for connecting to the server but i can't keep the connection open to run some other commands.

Does anyone know how to keep the connection open and run some commands?

Here is my current code:

use Symfony\Component\Process\Process;

$process = new Process("cf ssh APP-NAME");
$process->setPTY(true);

// Add some other commands like "php artisan migrate" 

$process->run();

echo $process->getOutput();

0 likes
0 replies

Please or to participate in this conversation.