PHPZabbix
Zabbix PHP API library based on [pyzabbix]0., (*1)
Example
$api = phpzabbix\PHPZabbix::withDefaultClient('http://example.com/zabbix/api_jsonrpc.php');
$api->login('username', 'password');
$hosts = $api->host->get(['output' => ['hostid', 'name']]);
It's also possible to directly set the authorization token, either obtained earlier by logging in, or an API token:, (*2)
$api = phpzabbix\PHPZabbix::withDefaultClient('http://example.com/zabbix/api_jsonrpc.php');
$api->authToken = 'abcdef123456';
$hosts = $api->host->get(['output' => ['hostid', 'name']]);
Error handling
The following exceptions can be thrown:, (*3)
-
phpzabbix\Exception\NotAuthorized
when trying to make an API call with an
invalid or expired auth hash., (*4)
-
phpzabbix\Exception\InvalidCredentials
when trying to login with invalid
credentials., (*5)
-
phpzabbix\JSONRPC\ErrorException
on other errors, such as invalid API calls, (*6)
Documentation
The PHPZabbix class does not know every API call, but just translates
$api->obj->method()
to 'obj.method'. The method call takes an array which
is passed as params., (*7)
Refer to the Zabbix API for more information about the Zabbix API
itself., (*8)
Compattibility
This library should work with Zabbix 3.0 and higher. Older versions should also
work, but that has not been verified., (*9)
License
This code is distributed under the GPLv3 license., (*10)