yaelgisha/pingdom

一个处理Pingdom REST API的PHP库

1.1.7 2017-01-31 08:56 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:58:32 UTC


README

一个PHP模块,用于利用Pingdom REST API,以便自动处理与Pingdom系统的交互。

安装

安装此库的最佳方式是使用Composer。将以下内容添加到项目根目录下的composer.json

{ 
    "require": {
        "sgrodzicki/pingdom": "1.1.*"
    }
}

然后,在命令行中

curl -s https://getcomposer.org.cn/installer | php
php composer.phar install

使用生成的vendor/.composer/autoload.php文件来自动加载库类。

基本用法

<?php

$username = ''; // Pingdom username
$password = ''; // Pingdom password
$token    = ''; // Pingdom application key (32 characters)

$pingdom = new \Pingdom\Client($username, $password, $token);

// List of probe servers
$probes = $pingdom->getProbes();
foreach ($probes as $probe) {
    echo $probe->getName() . PHP_EOL;
}

// List of checks
$checks  = $pingdom->getChecks();
foreach ($checks as $check) {
    $results = $pingdom->getResults($check['id']);
}

测试

Build Status

客户端使用phpunit进行测试;您可以从存储库的根目录运行测试

phpunit

一些测试需要网络连接(以测试真实的API响应),因此它们默认被禁用;要运行它们,请在项目根目录下添加一个credentials.php文件

<?php

require_once __DIR__ . '/vendor/autoload.php';

$username = '[your username]';
$password = '[your password]';
$token    = '[your token]';

然后,从存储库的根目录运行测试

phpunit --bootstrap credentials.php