anexia-it/php-cloudlog

CloudLog PHP client library

v0.5.1 2018-03-27 19:39 UTC

This package is not auto-updated.

Last update: 2025-03-02 05:49:33 UTC


README

php-cloudlog is a client library for Anexia CloudLog.

Currently it only provides to push events to CloudLog. Querying is possible in a future release.

There are two connection types:

  • directly connected for high throughput
    • requires php-rdkafka (relies on librdkafka >= 0.9.1)
  • http client

Get started

$ composer require anexia-it/php-cloudlog

composer.json

{
    "require": {
        "anexia-it/php-cloudlog": "<2.0.0"
    }
}

Quickstart

<?php

use CloudLog\Client;

// Init CloudLog client
$client = Client::create("index","ca.pem","cert.pem","cert.key");

// Alternative CloudLog client (http)
$client = Client::createHttp("index","token");

// Push simple message
$client->pushEvent("message");

// Push document (multiple formats supported: object, assoc array, json string)

// object
class Event {
    public $timestamp;
    public $user;
    public $message;
    public $severity;
}

$event = new Event();
$event->timestamp = 1495024205123;
$event->user = "test";
$event->severity = 1;
$event->message = "My first CloudLog event";

$client->pushEvent($event);

// associative array
$client->pushEvent([
    "timestamp" => 1495024205123,
    "user" => "test",
    "severity" => 1,
    "message" => "My first CloudLog event"
]);

// json string
$client->pushEvent('{
  "timestamp": 1495024205123,
  "user": "test",
  "severity": 1,
  "message": "My first CloudLog event"
}');