zingle/zi-agent

Zingle infrastructure agent

v2.0.0 2020-11-10 21:47 UTC

This package is auto-updated.

Last update: 2024-03-24 23:43:09 UTC


README

Build Status Coverage Status

Installation

composer require zingle/zi-agent

Usage

use Zingle\Infrastructure\Agent;
use Zingle\Infrastructure\Connection;

$key = new \phpseclib\Crypt\RSA("-----BEGIN RSA PRIVATE KEY-----\nmTJJCjZ...");
$agent = new Agent("foo-user", $key);
$connection = new Connection("example.com", $agent);
$result = $connection->execute("my-command");

if ($result->getExit() !== 0) {
    echo $result->getOutput();
    echo "failed\n";
}

// if running multiple commands, explicitly open and close the connection
$connection->open();
// ... $result = $connection->execute("...");
// ... $result = $connection->execute("...");
$connection->close();