Reputation: 527
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
, which 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();
Upvotes: 0
Views: 2030
Reputation: 519
Executing commands on a remote server is a totally different feature that starting subprocesses. So it does not belong to the Process component but to another library. Try to use this one phpseclib/phpseclib here you can find nice manual phpseclib/phpseclib manual.
Or this one ssh-client/ssh-client.
Also, take a look at this laravel package laravelcollective/remote
Upvotes: 0