PHP code example of mangati / cachet

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

    

mangati / cachet example snippets


use Mangati\Cachet\Client;

$endpoint = 'https://demo.cachethq.io/api/v1/';
$token    = '9yMHsdioQosnyVK4iCVR';

$client = new Client($endpoint, $token);

$components = $client->getComponents();

foreach ($components as $component) {
    echo $component->getName();
}

$components = $client->getComponents([
    'sort' => 'id',
    'order' => 'desc'
]);

$component = $client->getComponent(3);

$component = new Component();
$component->setName('My new component');
$component->setDescription('Component description');
$component->setLink('https://github.com/mangati/cachet');
$component->setStatus(Component::STATUS_OPERATIONAL);

$client->addComponent($component);

$component = new Component();
$component->setId(3);
$component->setName('My new component (updated)');

$client->updateComponent($component);

$id = 3;

$client->deleteComponent($id);

$incidents = $client->getIncidents();

foreach ($incidents as $incident) {
    echo $incident->getName();
}

$incidents = $client->getIncidents([
    'sort' => 'id',
    'order' => 'desc'
]);

$incident = $client->getIncident(3);

$incident = new Incident();
$incident->setName('My new incident');
$incident->setMessage('incident message');
$incident->setStatus(Incident::STATUS_WATCHING);

$client->addIncident($incident);

$incident = new Incident();
$incident->setId(3);
$incident->setStatus(Incident::STATUS_FIXED);

$client->updateIncident($incident);

$id = 3;

$client->deleteIncident($id);

PHP Fatal error:  Uncaught exception 'Doctrine\Common\Annotations\AnnotationException' with message '[Semantical Error] The annotation "@JMS\Serializer\Annotation\Type" in property (...) does not exist, or could not be auto-loaded.'

Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('JMS\Serializer\Annotation', $rootDir . "/vendor/jms/serializer/src");