mangati / cachet
Cachet client
v1.0.1
2018-01-08 14:32 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: ~6.0
- jms/serializer: ~1.1
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-10-16 02:33:55 UTC
README
Cachet PHP client.
About Cachet
Cachet is an open source status page system written in PHP. https://github.com/CachetHQ/Cachet.
Usage
Setup
use Mangati\Cachet\Client; $endpoint = 'https://demo.cachethq.io/api/v1/'; $token = '9yMHsdioQosnyVK4iCVR'; $client = new Client($endpoint, $token);
Components
Get components
$components = $client->getComponents(); foreach ($components as $component) { echo $component->getName(); }
Sorting
$components = $client->getComponents([ 'sort' => 'id', 'order' => 'desc' ]);
Get by id
$component = $client->getComponent(3);
Create new component
$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);
Update an existing component
$component = new Component(); $component->setId(3); $component->setName('My new component (updated)'); $client->updateComponent($component);
Delete an existing component
$id = 3; $client->deleteComponent($id);
Incidents
Get incidents
$incidents = $client->getIncidents(); foreach ($incidents as $incident) { echo $incident->getName(); }
Sorting
$incidents = $client->getIncidents([ 'sort' => 'id', 'order' => 'desc' ]);
Get by id
$incident = $client->getIncident(3);
Create new incident
$incident = new Incident(); $incident->setName('My new incident'); $incident->setMessage('incident message'); $incident->setStatus(Incident::STATUS_WATCHING); $client->addIncident($incident);
Update an existing incident
$incident = new Incident(); $incident->setId(3); $incident->setStatus(Incident::STATUS_FIXED); $client->updateIncident($incident);
Delete an existing incident
$id = 3; $client->deleteIncident($id);
Known issue
Doctrine annotation error:
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.'
Can fix it registering the JMS namespace:
Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('JMS\Serializer\Annotation', $rootDir . "/vendor/jms/serializer/src");