ikke / phpzabbix
PHP Zabbix API Client
Installs: 12 844
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 1
Open Issues: 2
pkg:composer/ikke/phpzabbix
Requires
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is not auto-updated.
Last update: 2025-12-25 03:16:52 UTC
README
Zabbix PHP API library based on pyzabbix.
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:
$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:
-
phpzabbix\Exception\NotAuthorizedwhen trying to make an API call with an invalid or expired auth hash. -
phpzabbix\Exception\InvalidCredentialswhen trying to login with invalid credentials. -
phpzabbix\JSONRPC\ErrorExceptionon other errors, such as invalid API calls
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.
Refer to the Zabbix API for more information about the Zabbix API itself.
Compattibility
This library should work with Zabbix 3.0 and higher. Older versions should also work, but that has not been verified.
License
This code is distributed under the GPLv3 license.