PHP

Installation

composer require enalog/enalog-php

Usage

The PHP SDK has a client that requires you to pass your EnaLog API token. The example below shows a full example of how to send an event to EnaLog.

use EnaLog\EnaLogClient;

$enalogClient = new EnaLogClient('api-token');

$enalogClient->pushEvent([
    'project' => 'hello-world',
    'name' => 'testing-php',
    'description' => 'hello world event description',
    'icon' => '👀',
    'tags' => ['hello', 'world'],
    'meta' => ['meta' => 'data'],
    'channels' => [],
    'user_id' => '1234'
]);

Exceptions

If the EnaLog PHP SDK fails to send an event it will throw an exception called EnaLogEventException. You should aim to catch this exception in your application. The example below shows you an example of how to do this:

use EnaLog\EnaLogClient;
use EnaLog\EnaLogEventException;

$enalogClient = new EnaLogClient('api-token');

try {
    $enalogClient->pushEvent([
        'project' => 'hello-world',
        'name' => 'testing-php',
        'description' => 'hello world event description',
        'icon' => '👀',
        'tags' => ['hello', 'world'],
        'meta' => ['meta' => 'data'],
        'channels' => [],
        'user_id' => '1234'
    ]);
} catch (EnaLogEventException $e) {
    // Do something with the error
}