PHP code example of ghostcompiler / laravel-hetzner-robot
1. Go to this page and download the library: Download ghostcompiler/laravel-hetzner-robot 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/ */
ghostcompiler / laravel-hetzner-robot example snippets
use Vendor\HetznerRobot\Facades\HetznerRobot;
// List all servers
$servers = HetznerRobot::servers()->all();
foreach ($servers as $server) {
echo $server->serverName . ': ' . $server->serverIp . "\n";
}
// Find a server by number
$server = HetznerRobot::servers()->find(321);
echo "DC: " . $server->dc;
// Rename a server
$server = HetznerRobot::servers()->update(321, [
'server_name' => 'production-web-01'
]);
// Cancel a server
$cancellation = HetznerRobot::servers()->createCancellation(321, [
'cancellation_reason' => 'no_longer_needed'
]);
echo "Cancellation status: " . $cancellation->cancellationDate;
// List all IP addresses
$ips = HetznerRobot::ips()->all();
// Update reverse DNS (PTR)
$rdns = HetznerRobot::rdns()->create('123.123.123.123', 'your-domain.com');
// Enable MAC address for IP
$mac = HetznerRobot::ips()->updateMac('123.123.123.123', '00:11:22:33:44:55');
// Enable rescue system for server
$rescue = HetznerRobot::boots()->enableRescue(321, [
'os' => 'linux',
'arch' => 64
]);
echo "Temp password: " . $rescue->password;