mangati / cachet
Cachet 客户端
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-09-16 02:20:35 UTC
README
Cachet PHP 客户端。
关于 Cachet
Cachet 是一个用 PHP 编写的开源状态页面系统。 https://github.com/CachetHQ/Cachet.
用法
设置
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' ]);
通过 ID 获取
$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' ]);
通过 ID 获取
$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);
已知问题
Doctrine 注解错误
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.'
可以通过注册 JMS 命名空间来修复它
Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('JMS\Serializer\Annotation', $rootDir . "/vendor/jms/serializer/src");