PHP code example of zuogechengxu / zabbix

1. Go to this page and download the library: Download zuogechengxu/zabbix 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/ */

    

zuogechengxu / zabbix example snippets

 php
use Zuogechengxu\Zabbix\Application;

$zbx_config = [
    'zabUrl' => 'http://xxx.xx.xx.xx',
    'zabUser' => 'Admin',
    'zabPassword' => 'zabbix'
];

$app = new Application($zbx_config);
 php
use Zuogechengxu\Zabbix\Application;

# 使用以下方法可以直接调用 Zabbix 任意 API,该方法默认自动处理了用户令牌逻辑,以获取主机为例。
$params = [
    "filter" => ["host" => ['Zabbix server']]
];

# 返回数据
$host = $app->rpc->call('host.get', $params)

# 返回原始 response 对象
$host = $app->rpc->call('host.get', $params, true)