PHP code example of zingle / zi-agent
1. Go to this page and download the library: Download zingle/zi-agent library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zingle / zi-agent example snippets
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();