PHP client for IPMI/Redfish API communication.
composer require sunfox/redfish-clientuse Sunfox\RedfishClient\Client;
$client = new Client(
baseUrl: "https://192.168.x.x",
username: "ADMIN",
password: "password",
timeout: 3.0,
verifySsl: false,
);
// Get power state
$powerState = $client->getPowerState();
if ($powerState->isOn()) {
echo "Server is ON\n";
}
// Get power consumption
$consumption = $client->getPowerConsumption();
echo "Current power: {$consumption->currentWatts}W\n";
// Get system info
$systemInfo = $client->getSystemInfo();
echo "Manufacturer: {$systemInfo->manufacturer}\n";
echo "Model: {$systemInfo->model}\n";
// Check if reachable
if ($client->isReachable()) {
echo "Server is reachable\n";
}use Sunfox\RedfishClient\Exception\AuthenticationException;
use Sunfox\RedfishClient\Exception\ConnectionException;
use Sunfox\RedfishClient\Exception\RedfishException;
try {
$powerState = $client->getPowerState();
} catch (AuthenticationException $e) {
echo "Invalid credentials\n";
} catch (ConnectionException $e) {
echo "Cannot connect to server\n";
} catch (RedfishException $e) {
echo "Redfish API error: {$e->getMessage()}\n";
}MIT License. See LICENSE for details.