PHP code example of checkitonus / statuspage-sdk

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

    

checkitonus / statuspage-sdk example snippets




use CheckItOnUs\StatusPage\Server;

$server = new Server([
    'api_key' => 'API-KEY',
    'base_url' => 'https://api.statuspage.io/v1/pages'
]);

// Should return your first component
echo $server->components()->first()->toApi();



use CheckItOnUs\StatusPage\Server;
use CheckItOnUs\StatusPage\Component;

$server = new Server([
    'api_key' => 'API-KEY',
]);

// Find a component based on the name
$component = Component::on($server)->findByName('API');

// Find a component based on the ID
$component = Component::on($server)->findById(1);

// Find all components
Component::on($server)->all();



use CheckItOnUs\StatusPage\Server;
use CheckItOnUs\StatusPage\Component;

$server = new Server([
    'api_key' => 'API-KEY',
]);

// Fluent API
$component = (new Component($server))
                ->setName('Name Here')
                ->setStatus(Component::OPERATIONAL)
                ->create();



use CheckItOnUs\StatusPage\Server;
use CheckItOnUs\StatusPage\Component;

$server = new Server([
    'api_key' => 'API-KEY',
]);

// Fluent API
Component::on($server)
    ->findById(1)
    ->setName('Name Here')
    ->setStatus(Component::OPERATIONAL)
    ->update();



use CheckItOnUs\StatusPage\Server;
use CheckItOnUs\StatusPage\Component;

$server = new Server([
    'api_key' => 'API-KEY',
]);

// Fluent API
Component::on($server)
    ->findById(1)
    ->delete();